C Program to print two dimensional array

Simple C program to print two dimensional array: To print two dimensional array, we run two for loop. One for one dimension and another for second dimension.
 
/* C program to print 2D array */
#include<stdio.h>
int main()
{
 int arr[3][3];
 int i,j;
 printf("Enter array elements: \n");
 for(i=0;i<3;i++)
 {
  for(j=0;j<3;j++)
  {
   printf("Enter %d%d elements: ",i,j);
   scanf("%d",&arr[i][j]);
  }
 }
 printf("Array is\n");
 for(i=0;i<3;i++)
 {
  for(j=0;j<3;j++)
  {
   printf("%d ",arr[i][j]);
  }
  printf("\n");
 }
 return 0;
}
/* End of the program */
 


Popular posts from this blog