ProgrammingVery hard
int m[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; int t = 0; for (int i = 0; i < 3; i++) t += m[i][i] * m[i][2 - i]; printf("%d", t); What is printed?
- A. 25
- B. 15
- C. 91
- D. 30
Correct answer: C. 91
The products are 1 x 3, 5 x 5 and 9 x 7, so the total is 3 + 25 + 63 = 91.
More C Programming questions
- int m[2][3] = {{1, 2, 3}, {4, 5, 6}}; int p = m[1]; printf("%d %d", p[0], (p + 2)); What is printed?
- int m[2][3]; int p = &m[0][0]; for (int i = 0; i < 6; i++) p[i] = i i; printf("%d", m[1][2]); What is printed?
- A rectangular table with R rows and C columns is traversed in a loop that touches each cell once in row-major order. Which total cost is…
- Which declaration makes a pointer that walks row by row through an int matrix with 6 columns?
- For an int matrix a with R rows and C columns stored in row-major order, what is the flat index of the cell at (r, c) in terms of R?
- A matrix of 10 x 10 is searched linearly for a value. About how many cell reads happen in the worst case?