ProgrammingHard
int d[2][3] = {1, 2, 3, 4, 5, 6}; printf("%d", d[1][0]); What is printed?
- A. 4
- B. 3
- C. 5
- D. 1
Correct answer: A. 4
The brace list fills the array in row-major order, so d[1] starts with the fourth value, 4.
More C Programming questions
- int m[2][2] = {{1, 2}, {3, 4}}; int t[2][2]; for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) t[j][i] = m[i][j]; printf("%d"…
- 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…
- 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?