Consider a 20 × 5 two-dimensional array Marks with base address 1000. Each…

2025

Consider a 20 × 5 two-dimensional array Marks with base address 1000. Each array element occupies 2 words. Assuming zero-based indexing and row-major storage, compute the address of Marks[18, 4].

Show answer & explanation

Concept

For a two-dimensional array with C columns stored in row-major order, the zero-based element offset of A[i, j] is i × C + j.

If each element occupies w words, its address is Base + w × (i × C + j). The row count limits valid indices but does not otherwise enter this offset formula.

Application

  1. Here C = 5, i = 18, j = 4, w = 2, and Base = 1000.

  2. The element offset is 18 × 5 + 4 = 94 elements.

  3. The word offset is 94 × 2 = 188 words.

  4. Therefore, the address is 1000 + 188 = 1188.

Cross-check

Each complete row occupies 5 × 2 = 10 words. Eighteen complete rows occupy 180 words, and the four preceding elements in row 18 occupy 4 × 2 = 8 words. Thus the total offset is 180 + 8 = 188 words, confirming the calculation.

Result

The address of Marks[18, 4] is 1188.

Explore the full course: Up Lt Grade Assistant Teacher 2025

Loading lesson…