GATE CS 2002 · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0249

Consider the following declaration of a two-dimensional array in C :char a[100][100];Assuming that the main memory is byte-addressable and that array is stored starting from memory address 0, the address of a [40] [50] is
  1. A
    4040
  2. B
    4050
  3. C
    5040
  4. D
    5050

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

Show the worked solution\[\boxed{\text{address of } a[i][j]=\text{base}+(i\times\text{columns}+j)\times\text{element size}}\]C stores arrays in row-major order and a char takes \(1\) byte: \(0+(40\times100+50)\times1=4050\).Answer: B

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