C Multidimensional Array : Memory Representation

Memory Representation

  1. 2-D arrays are Stored in contiguous memory location row wise.
  2. 3 X 3 Array is shown below in the first Diagram.
  3. Consider 3×3 Array is stored in Contiguous memory location which starts from 4000 .
  4. Array element a[0][0] will be stored at address 4000 again a[0][1] will be stored to next memory location i.e Elements stored row-wise
  5. After Elements of First Row are stored in appropriate memory location , elements of next row get their corresponding mem. locations.

Multi Dimensional Array in C Programming

  1. This is integer array so each element requires 2 bytes of memory.

Basic Memory Address Calculation :

a[0][1] = a[0][0] + Size of Data Type

ElementMemory Location
a[0][0]4000
a[0][1]4002
a[0][2]4004
a[1][0]4006
a[1][1]4008
a[1][2]4010
a[2][0]4012
a[2][1]4014
a[2][2]4016

Memory Address Location in Multi Dimensional Array in C Programming