ProgrammingVery hard

unsigned int u = 1; int s = -2; printf("%u", u + s); What is printed with 32-bit unsigned int?

  1. A. 4294967294
  2. B. -1
  3. C. 2
  4. D. 4294967295

Correct answer: D. 4294967295

s is converted to unsigned int, giving 2^32 - 2, and adding 1 wraps to 2^32 - 1.

More C Programming questions

Exams that ask this topic