ProgrammingHard
int a[2][3] with a pointer p = &a[0][0]. Which expression gives the number of elements between a[0][0] and a[1][2]?
- A. 5
- B. 6
- C. 4
- D. 3
Correct answer: A. 5
a[1][2] is at flat index 1 * 3 + 2 = 5 from a[0][0], so its offset from &a[0][0] is 5 elements.
More C Programming questions
- The sum of the elements of a[i][j] = i j over the 4 x 4 matrix equals what?
- Which statement about matrix multiplication in C is correct for an m x k matrix times a k x n matrix?
- Sum of a 2 x 2 window of m[i][j] = i + j starting at (1,1) in a 4 x 4 grid, i.e. m[1][1] + m[1][2] + m[2][1] + m[2][2]. What is the value?
- In a 2D array with int a[5][5], what is the total number of bytes in one row when int is 4 bytes?
- What is the most efficient way to check whether an n x n matrix is symmetric in O(n^2)?
- A 3 x 4 matrix holds a[i][j] = i 4 + j + 1. What is the sum of its boundary cells (first and last row, first and last column)?