ProgrammingHardTCS NQT · Infosys

Which type reliably holds the sum 1 + 2 + ... + 100000 = 5000050000?

  1. A. int
  2. B. unsigned int
  3. C. uint64_t
  4. D. uint16_t

Correct answer: C. uint64_t

5000050000 is larger than both 2^31 and 2^32, so int and unsigned int overflow. A uint64_t holds it without wrap.

More C Programming questions

Exams that ask this topic