Two dimensional array

Two dimensional array :

Two-dimensional array can be though as a rectangular display of elements with rows and columns. For  example elements of int x [3] [3] are shown in the below table..
         Array Elements in matrix form

Col1
Col2
Col3
Row1
X [0] [0]
X [0] [1]
X [0] [2]
Row2
X [1] [0]
X [1] [1]
X [1] [2]
Row3
X [2] [0]
X [2] [1]
X [2] [2]





The arrangement of array elements are shown in the above table is only is only for the sake of understanding.Conceptually the elements are shown in matrix form.physically array elements are stored in one continuous form in the memory.
The two dimensional array is a collection of a number of one-dimensional arrays,which are placed one after another.for example in the above table each row of a two dimensional array can be though of as a single dimensional array.
Example :
#include<stdio.h>
#include<conio.h>
void main( )
{
int i,j;
int a[3] [3]={{1,2,3},{4,5,6},{7,8,9}};
printf("Array elements and addresses\n\n");
printf("col-0   col-1   col-2\n");
printf("row");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
printf("%d [%5d]",a[i][j],&a[i][j]);
printf("\nRow %d",i+1);
}
printf("\r  ");
}
OUTPUT :
Array elements and addresses 
               col-0               col-1        col-2
Row 0   1[4052]           2[4054]     3[4056]
Row 1   4[4058]           5[4060]     6[4062]    
Row 2   7[4064]           8[4066]     9[4068]

Explanation :
In the above program two-dimensional array is declared and initialised.using two nested for loops elements of an array together with their addresses are displayed.it is shown that the output elements of two of two dimensional array are displayed in a rectangular form.but in memory they are not stored in this particular format . they are stored in a particular memory location as shown in below table......
                                      Memory map of two dimensional array elements
Row,col        
a[0][0]  
a[0][1]  
a[0][1]  
a[1][0]  
a[1][1]  
a[1][2]  
a[2][0]  
a[2][1]  
 a[2][2]
value  
1
2
3
4
5
6
7
8
9
address  
4052    
4054
4056
4058
4060
4062
4064
4066
4068