ProgrammingHardTCS NQT · Infosys

uint32_t x = 0x7FFFFFFFu; x = x * 2u + 1u; What is x?

  1. A. 4294967295
  2. B. 0
  3. C. 4294967294
  4. D. 2147483647

Correct answer: A. 4294967295

x * 2u wraps to 0xFFFFFFFE, and adding 1u gives 0xFFFFFFFF, which is 4294967295. The value never leaves the unsigned range, so the result is defined.

More C Programming questions

Exams that ask this topic