ProgrammingHardTCS NQT · Infosys

uint32_t v = 0; for each digit d of the decimal string "4294967296", v = v * 10 + d; What is v at the end?

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

Correct answer: D. 0

Unsigned arithmetic wraps modulo 2^32, and 4294967296 is exactly 2^32, so v becomes 0. Parsing large numbers into fixed-width unsigned types needs an explicit overflow check.

More C Programming questions

Exams that ask this topic