Initialization of Two-Dimensional Array in C

void main()
   {
   int i,j;
   int num[3][3]={{1,2,3},{4,5,6},{7,8,9}};
   clrscr();
   printf("Elements of two-dimensional array:\n\n");
   for(i=0;i<=2;i++)
   {
   for(j=0;j<=2;j++)
   printf("%5d",num[i][j]);
   printf("\n");
   }
   getche();
   }

Output

Elements of two-dimensional array:

1 2 3

4 5 6

7 8 9

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.