Two dimensional Arrays
C language supports multidimensional arrays. The simplest form of the multidimensional array is the two-dimensional array.
Two-dimensional array is declared as follows,
type array-name[row-size][column-size] Example : int a[3][4];
The above array can also be declared and initialized together. Such as,
int arr[][3] = {
{0,0,0},
{1,1,1}
};
Run-time initialization of two dimensional Array
#include<stdio.h>
#include<conio.h>
void main()
{
int arr[3][4];
int i,j,k;
printf("Enter array element");
for(i=0;i<3;i++)
{
for(j=0; j < 4; j++)
{
scanf("%d",&arr[i][j]);
}
}
for(i=0; i < 3; i++)
{
for(j=0; j < 4; j++)
{
printf("%d",arr[i][j]);
}
}
getch();
}
No comments:
Post a Comment