ProgrammingHard
unsigned char a = 200, b = 100; unsigned char c = a + b; printf("%d", c); What is printed?
- A. 44
- B. 300
- C. 256
- D. -56
Correct answer: A. 44
a + b is computed as int, 300, and the store into an unsigned char keeps only the low 8 bits: 300 mod 256 = 44.
More C Programming questions
- In C99 and later, what are the values of (-7) / 2 and (-7) % 2?
- The modular inverse of 3 modulo 1000000007 is which value?
- Which expression is correct for (a b) % MOD with MOD = 1000000007 and 0 <= a, b < MOD, to avoid overflow in C?
- How many times does the loop x &= x - 1 run for x = 0b101100 before x becomes 0?
- For unsigned x = 40 (binary 101000), what is x & -x?
- Reversing the 8 bits of 0b00010110 gives which value in decimal?