ProgrammingHardGATE CS · Campus placements
For an int, what is the value of ~5 + 1?
- A. -5
- B. 9
- C. -6
- D. 4
Correct answer: A. -5
~5 is -6 in two's complement, since ~x = -x - 1 for signed integers. Adding 1 gives -5.
More C Programming questions
- int x = 12; x = x ^ (x >> 2); What is x?
- Six people stand in a circle numbered 1 to 6; starting from 1, every second person is removed until one remains. Which number survives?…
- Seven people stand in a circle numbered 1 to 7. Starting from person 1, every third person is removed until one remains. Which number…
- unsigned char a = 200, b = 100; unsigned char c = a + b; printf("%d", c); What is printed?
- In C99 and later, what are the values of (-7) / 2 and (-7) % 2?
- The modular inverse of 3 modulo 1000000007 is which value?