ProgrammingVery hard
With int a[3][4] (4-byte int) and int (*p)[4] = a, what is (char *)(p + 2) - (char *)p?
- A. 8
- B. 16
- C. 32
- D. 24
Correct answer: C. 32
p + 2 advances two whole rows, each of 4 ints of 4 bytes, so 2 x 16 = 32 bytes. The pointer step counts whole rows, not single ints.
More C Programming questions
- 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…
- Count the 4-connected islands of 1s in this grid, where rows are "11000", "11010", "00100", "00011". How many islands are there?
- In Pascal's triangle with row 0 at the top, what is the entry in row 6, column 2?