Two Dimensional array


A two dimensional array is specified  using two subscripts where one subscript denotes row and the other denotes column. C consider the two-dimensional array as an array of a one-dimensional array.
Declaration of Two-dimensional Array
Similar to one dimensional arrays.two dimensional arrays must be declared before being used.The declaration statement tells the compiler the name of the array the data type of each in the array,and the size of each dimension.Two dimensional array is declared as:
data_type array_name[row_size][column_size];



Write a program to print the elements of a 2D array

#include<stdio.h>
#include<conio.h>
void main()
{
int arr[2][2]={12,34,56,32};
int i,j;
for(i=0;i<2;i++)
{
printf("\n");
for(j=0;j<2;j++)
printf("%d\t",arr[i][j]);
}
getch();
}



Output

12 34

56 32

Comments