ProgrammingHardGATE CS · Campus placements

uint32_t x = 1u; x <<= 31; x <<= 1; What is x afterwards?

  1. A. 0
  2. B. 2147483648
  3. C. 4294967296
  4. D. 1

Correct answer: A. 0

Left shifts of an unsigned value discard bits beyond its width, so the set bit moves out of the 32-bit range. The result is 0, not undefined behaviour.

More C Programming questions

Exams that ask this topic