Consider the following declaration of a two-dimensional array in C:
char ;
Assuming that the main memory is byte-addressable and that the array is stored starting from memory address , the address of is:
View worked solution
Answer: B
In C, two-dimensional arrays are stored in row-major order. This means elements are stored row by row in contiguous memory locations.
For a 2D array declared as char a[M][N], the memory address of the element at index [i][j] is calculated using the formula:
Given the following values from the question:
- Array declaration:
char a[100][100], so the number of columns . - Base Address =
- Target element:
a[40][50], so and . - Since the array is of type
char, the size of each element is byte (under standard byte-addressable memory).
Substituting these values into the formula:
Therefore, the address of a[40][50] is 4050.
Free practice · Your answers on this page are not saved.
