ProgrammingHard
int a[3][4]; for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) a[i][j] = i * 4 + j; printf("%d", *(&a[0][0] + 7)); What is printed?
- A. 7
- B. 6
- C. 8
- D. 11
Correct answer: A. 7
With int a[3][4] stored in row-major order, the element at flat index 7 is a[1][3], and that holds 1 * 4 + 3 = 7.
More C Programming questions
- With int a[3][4] (4-byte int, row-major), what is the value of (int )&a[1][0] - (int )&a[0][0]?
- With int a[3][4] (4-byte int) and int (p)[4] = a, what is (char )(p + 2) - (char )p?
- Matrix m = {{1,2,3},{4,5,6},{7,8,9}} is rotated 90 degrees clockwise. What is the first row after rotation?
- Matrix m = {{1,2,3},{4,5,6},{7,8,9}} is transposed in place. What is the first row afterwards?
- Spiral traversal (clockwise, starting top-left) of the 3 x 4 matrix with rows {1,2,3,4}, {5,6,7,8}, {9,10,11,12} visits the elements in…
- int g[3][3] = {{1,2,3},{4,5,6},{7,8,9}}; With a 2D prefix-sum table P, the sum of the rectangle with rows 1 to 2 and columns 1 to 2…