ProgrammingHard

int c = 0; for (int i = 0; i < 4; i++) for (int j = 0; j < i * i; j++) c++; printf("%d", c); What is printed?

  1. A. 14
  2. B. 16
  3. C. 10
  4. D. 9

Correct answer: A. 14

The inner loop runs 0, 1, 4 and 9 times for i = 0 to 3. The total is 14, which is about n^3 / 3 in general.

More C Programming questions

Exams that ask this topic