ProgrammingHardTCS NQT · Infosys

With uint32_t x = 5u - 7u; what is the value of x?

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

Correct answer: B. 4294967294

Unsigned arithmetic wraps modulo 2 to the power 32, so 5 - 7 becomes 2^32 - 2 = 4294967294. An unsigned type never holds a negative value.

More C Programming questions

Exams that ask this topic