ProgrammingModerate

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

  1. A. 49
  2. B. 21
  3. C. 0
  4. D. 7

Correct answer: D. 7

The inner if is true only when i == j, once per row, so 7 of the 49 pairs count. 49 ignores the condition, and 21 counts the pairs with i < j instead.

More C Programming questions

Exams that ask this topic