ProgrammingHardTCS NQT · Infosys

uint32_t a = 4000000000u; uint32_t s = a + a; What is s?

  1. A. 8000000000
  2. B. -294967296
  3. C. 3705032704
  4. D. 4000000000

Correct answer: C. 3705032704

Unsigned addition is reduced modulo 2^32 (4294967296): 8000000000 - 4294967296 = 3705032704. The result always stays in range, so no undefined behaviour occurs.

More C Programming questions

Exams that ask this topic