A three dimensional array in C++ is declared as int A[a][b][c]. Consider that…
2023
A three dimensional array in C++ is declared as int A[a][b][c]. Consider that array elements are stored in row major order and indexing begins from 0. Here the address of an item at the location A[r][s][t] computed in terms of word length w of an integer is
Attempted by 35 students.
Show answer & explanation
r counts full blocks of size b×cb
s counts full rows of length c
t counts the offset in that row
So total offset from base is:
r(bc)+s(c)+t
and since each integer takes www words:
Address=Base+w[rbc+sc+t]
A video solution is available for this question — log in and enroll to watch it.