All mock tests are FREE till 31 December — register to save your progress

A three-dimensional array in C++ is declared as int A[a][b][c]. Array elements are stored in row-major order and indexing begins from 0. The address of the element A[r][s][t], in terms of the word length w of an integer, is

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. &A[0][0][0] + w(b·c·r + c·s + t)

Explanation

Before A[r] there are r planes of b·c elements; within the plane, s rows of c elements; then t elements. Offset = b·c·r + c·s + t words.

More Programming Languages and Computer Graphics questions