What would be the equivalent pointer expression for referring the array…
2025
What would be the equivalent pointer expression for referring the array element ar[m][n][o]
(1) * (* (* (ar) + m + n) + o)
(2) * (* (* ar + m) + n) + o)
(3) * (* ((ar + m) + n) + o)
(4) * (* (* (ar + m) + n) + o)
- A.
1
- B.
2
- C.
3
- D.
4
Attempted by 186 students.
Show answer & explanation
Correct answer: D
Correct expression: *(*(*(ar + m) + n) + o)
Why this is correct:
ar + m points to the m-th 2D subarray; applying * gives ar[m].
*(ar + m) + n points to the n-th 1D subarray inside ar[m]; applying * to that gives ar[m][n].
*(*(ar + m) + n) + o points to the o-th element of that 1D array; the final * returns ar[m][n][o].
Why the other given expressions are wrong:
Expressions that add m and n at the same pointer level (e.g., *((*(ar) + m + n) + o)) combine indices and end up addressing ar[m + n][...] rather than ar[m][n][...].
Forms that place + o outside the final dereference or omit the final * produce an integer plus o instead of indexing into the innermost array; they therefore fail to return ar[m][n][o].
Any expression that misses one level of dereference or combines levels of pointer arithmetic does not reflect the nested structure of a three-dimensional array and so is incorrect.
A video solution is available for this question — log in and enroll to watch it.