GATE 2021 CS (CS2) – Question 20
What is printed by this source C program under its contiguous-array addressing model?
#include <stdio.h>
int main() {
int arr[4][5],i,j;
for(i=0;i<4;i++)
for(j=0;j<5;j++) arr[i][j]=10*i+j;
printf("%d",*(arr[1]+9));
return 0;
}Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (C) 24
Explanation
In the source’s linear row-major address calculation, arr[1] starts at overall element five. Adding nine reaches overall element fourteen, row two,column four, whose value is twenty-four, C. Strict ISO C pointer arithmetic does not permit walking beyond the five-element row subarray this way, so the published answer relies on the intended flat-address interpretation rather than portable defined behaviour.