Similar questions 5 more →
Arrays & Strings
![Question 2.8, GATE 2002: C declares char a[100][100]. Memory is byte-addressable, and the array starts at address 0. What is the address of a[40][50]?
(A) 4040; (B) 4050; (C) 5040; (D) 5050.](../../assets/questions/CS-2002-Q33-1.webp)
Answer & solution
Answer: B (no official key was published)
Step 1: Compute the linear index before the byte address.
Step 2: There are 40 complete rows before row40, each contributing 100 characters, and 50 earlier characters within that row. Therefore the zero-based linear index is 4000+50=4050. Since sizeof(char)=1, no further scale factor is needed. The5040 alternative reverses the row and column roles.
Conclusion: C lays out rows contiguously in row-major order. Each char occupies one byte, and each row has 100 elements. The offset of a[40][50] is 40×100+50=4050 bytes, giving address 4050 from the stipulated zero base, B.