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?
- A. 14
- B. 5
- C. 10
- 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
- int t[1][3] = {{1, 2, 3}}; int u[3][1]; for (int i = 0; i < 1; i++) for (int j = 0; j < 3; j++) u[j][i] = t[i][j]; printf("%d", u[2][0])…
- char g[2][3] = {"xy", "z"}; printf("%c", g[0][1]); What is printed?
- int a[3][4] = {0}; a[2][3] = 9; int p = &a[0][0]; printf("%d", p[11]); What is printed?
- char s[] = "atb"; printf("%zu", strlen(s)); What is printed?
- char s[] = "x0y"; printf("%s", s); What is printed?
- char s[5] = "abc"; printf("%d", s[4]); What is printed?