ProgrammingHardTCS NQT · Infosys

What is the sum of the decimal digits of 2^20 = 1048576?

  1. A. 31
  2. B. 28
  3. C. 26
  4. D. 35

Correct answer: A. 31

The digits are 1, 0, 4, 8, 5, 7, 6, which sum to 31. Digit sums in competitive code are usually computed with a loop of n % 10 and n / 10.

More C Programming questions

Exams that ask this topic