GATE 2014 CS (CS2) – Question 44
A compiler generates this for C access X[i][j][k], with 32-bit int and 8-bit char:
t0 = i * 1024
t1 = j * 32
t2 = k * 4
t3 = t1 + t0
t4 = t3 + t2
t5 = X[t4]
Which declaration is correct?
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (A) int X[32][32][8];
Explanation
The kstride is4bytes, identifying int elements. The jstride32bytes means8elements in the final dimension. The istride1024bytes means32rows of32bytes each. Therefore **int X[32][32][8],A** matches the available declarations; the first dimension is selected from the listed choices.