Previous | Home | Next |
A simple traversing program in 2-D array
#include<conio.h>
void main()
{
int a[3][3], i=0, j=0;
clrscr();
printf("Enter the elements of the array :");
for (i=0;i<=2 ;i++ )
{
for(j=0; j<=2; j++)
{
scanf("%d\n", &a[i][j]); /* taking array elements as input from the user */
}
}
printf("\nThe elements of the array you have enetered are as follows :")
for(i=0; i<=2; i++)
{
for(j=0; j<=2; j++)
{
printf("%d", a[i][j]); /* diplaying the elements of the array */
}
}
getch();
}
Output :Its output will be as follows
Enter the elements of array :
1
2
3
4
5
6
7
8
9
The elements of the array you have entered are as follows :
1
2
3
4
5
6
7
8
9
Previous | Home | Next |