ProgrammingHard

int a[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; int s = 0; for (int i = 0; i < 3; i++) s += a[i][2 - i]; printf("%d", s); What is printed?

  1. A. 15
  2. B. 9
  3. C. 12
  4. D. 18

Correct answer: A. 15

The anti-diagonal cells are a[0][2] = 3, a[1][1] = 5 and a[2][0] = 7, which sum to 15.

More C Programming questions

Exams that ask this topic