For a while, assume that this 3-D array is of int type.
If I write int k = X[i][j][k]; Means I am looking for a particular integer value which is stored at the location *(X[i][j]+k) = *(*(X[i]+j)+k) = *(*(*(X+i)+j)+k)
Lets take an example of 1D array
if there is one 1D array A[10,20,30,40], Suppose, A is stored at 1000 location, intsize=4B
and If I write int k = A[2], means i am looking for an integer which is stored at *(A+2) location.
K = A[2]; Lets write intermediate code for this.
A[j]=*(Base Address + j*intsize)
A[j] = *(A + j*intsize) = *( 1000 + 2*4) = *(1008) = 30 ( our element)
t1 = j*intsize
t2 = baseAddress + t1
k = *(t2) it will give 30 to us.
Now, take an example of 2D array.
Int k = B[3][5]; It will also assign k with an integer value. We have to find the location of that integer.
Suppose array B has x rows and y columns, and stored in memory in ROW MAJOR Order.
k = B[i][j] = *(B +([i*no.Of_Cols]+j)*intsize)
k = B[3][5] = *(B + ((3*y) + 5)*4)
Suppose number of rows = 30, number of columns =20
k=B[3][4]= *(Base address + ((3*20)+5)*4) = *(B.A + 3*20*4 + 5*4) = *(1000 + 240+ 20) = *(1260).
To access, B[3][5], i can also write B[260/4] = B[65] = *(B + 65*4) = *(1000 + 260) = *(1260)
Intermediate code for k = B[i][j];
t1 = j*intsize = 5*4 = 20
t2 = i*#cols*instize = 3*20*4 = 240
t3 = t1+t2 = 260
k = B[t3]; *(1000 + 260) = *(1260);
PS: Assume Array B is stored at memory location 1000.
Let's take 3-D array now.
int k = C[i][j][k].
It means we have to cross, i 2D arrays, j 1D arrays, and k elements to reach our required element.
= B.A + (i_2D_arrays*no._elements_In_1_2D_Array + j*no._elements_in_1_1D_Array + k)*intsize
=B.A + (i_2D_arrays*no._elements_In_1_2D_Array*instsize + j*no._elements_in_1_1D_Array*intsize + k*intsize)
Now, we can see in question that k is multiplied by 4, hence array X is of int type. options (C) and (D) are eliminated here.
j is multiplied by 32, and this calculation equals to j*no._elements_in_1_1D_Array*intsize=j*32 = j*8*4
it means there are 8 elements in one 1D array.
int X[][][8]; so far so good to eliminate option B.
Let's go further.
i*1024 = i*no._elements_In_1_2D_Array*intsize
number of columns in 2D arrays = 8
number of rows in 2D arrays 256/8 = 32
Hence, there 2D array is of [32][8] size.
i*1024 = i*32*8*4 = i is number of 2D arrays, 32x8 is size of one D array.
We can't calculate number of 2D arrays by the given code, and that is not even required for our question.
So, the answer is (A).