ProgrammingModerate

A program increments a counter inside three nested loops, each running n = 100 times. How many increments occur?

  1. A. 10000
  2. B. 300
  3. C. 100000
  4. D. 1000000

Correct answer: D. 1000000

The innermost statement runs n x n x n = 100^3 = 10^6 times, because each outer iteration runs the full inner loops. 300 adds the loop counts, and 10000 counts only two levels of nesting.

More C Programming questions

Exams that ask this topic