## Two Dimensional Array

Two Dimensional Array can be represented using two subscripts.

Syntax
DataType ArrayName[Row-Size][Col-Size];
Here,
Row-Size indicates number of rows in an array.
Col-Size indicates number of columns in an array.
Example
int a;
Here,
a is an array having three rows and three columnsthat can store 9 values of type integer.

Number of elements that can be stored in two dimensional array can be  calculated using equation:
Row_Size * Column_Size
Thus in an array of 3 rows and 3 columns we can store 9 elements.
Individual element of two dimensional array can be identify using an array name along with row-index and column-index. Row-Index and Column-Index in two dimensional array always starts with 0. So First element is a, second is a and so on.

 a a a a a a a a a

Ammount of memory occupied by an array can be calculated using equation:
TotalMemory=RowSize*ColSize*Bytes Occupied By Data Type
Example:
float a;
= 2 * 3 * 4 (float Occupies 4 Bytes) = 24 Bytes
int a;
= 3 * 3 * 2 (integer Occupies 2 Bytes) = 18 Bytes
Bydefault all the elements of two dimensional array are initialized to 0.
It is also possible to initialize all the elements of two dimensional array at the time of declaring array(Compile Time).

Syntax
DataType ArrayName[Row-Size][Col-Size]= {Values};
Example
int a={1,2,3,4,5,6,7,8,9};

If number of values specified in curly bracket is less then the number of elements in an array then remaining elements are initialized with 0.
If number of values specified in curly bracket is greater then the number of elements in an array then compiler will generate error.
It is also possible to initialize an array at run time.

Example
int i,j,a;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("Enter Value:");
scanf("%d",&a[i][j]);
}
}
Multi Dimensional Array

Multi Dimensional Array can be represented using more then two subscripts.

Syntax
DataType ArrayName[Dim1][Dim2]...[DimN];
Example
int a;
Here,
a is an array that can store 24 values of type integer.