ProgrammingHard

int r[3][2] = {{1, 9}, {2, 3}, {5, 5}}; int best = 0; for (int i = 0; i < 3; i++) { int s = r[i][0] + r[i][1]; if (s > best) best = s; } printf("%d", best); What is printed?

  1. A. 14
  2. B. 5
  3. C. 10
  4. D. 7

Correct answer: C. 10

Row sums are 1 + 9 = 10, 2 + 3 = 5 and 5 + 5 = 10; best changes only on a strictly larger sum, so it stays 10. 5 is the smallest row sum, and 14 adds the column maxima (5 + 9).

More C Programming questions

Exams that ask this topic