Curated · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0279

Consider the following declaration of a multi-dimensional array in C : int a[4][16][4][8]Assuming that the main memory is byte-addressable and that array is stored starting form memory address 1000 in row-major order, the address of a[2][8][2][4] isNOTE: size of int datatype is 4 Byte.
  1. A
    1024
  2. B
    6200
  3. C
    2048
  4. D
    5200

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solutionFor n-dimensional array declared as \(int \;\; a[n_1][n_2]...[n_n]\), general formula to calculate address of any element \(int \;\; a[i_1][i_2]...[i_n]\) is \(=\text{Base Address of array}+ \left \{ (i_1 \times n_2 \times n_3 \times ... n_n )+ (i_2\times n_3\times n_4 \times ...n_n )+...+(i_{n-2}\times n_n ) + i_n\right \}\times sizeof({int})\)Address of a[2][8][2][4] is 1000+{(2*16*4*8)+(8*4*8)+(2*8)+4}*4 =6200Click to Join Our Telegram Group for Latest Update of MOCK TEST Click Here to Practice ALL Previous MOCK TEST FREE

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com