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)

  1. A.

    1

  2. B.

    2

  3. C.

    3

  4. D.

    4

Attempted by 186 students.

Show answer & explanation

Correct answer: D

Correct expression: *(*(*(ar + m) + n) + o)

Why this is correct:

  1. ar + m points to the m-th 2D subarray; applying * gives ar[m].

  2. *(ar + m) + n points to the n-th 1D subarray inside ar[m]; applying * to that gives ar[m][n].

  3. *(*(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.

Explore the full course: Mppsc Assistant Professor