ProgrammingHardGATE CS · Campus placements

int n = 0; reading the expression as C does: What is the value of ~5 + 1?

  1. A. -5
  2. B. 9
  3. C. -6
  4. 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

Exams that ask this topic