ProgrammingHardTCS NQT · Infosys

uint16_t a = 40000, b = 40000; uint32_t s = a + b; What is s?

  1. A. 14464
  2. B. 80000
  3. C. 0
  4. D. 65536

Correct answer: B. 80000

a and b promote to int, so a + b is 80000, which fits in uint32_t. Storing the sum in a 16-bit type would instead give 14464 because of the wrap.

More C Programming questions

Exams that ask this topic