C program to print matrix by using two-dimensional array



// C program to print matrix by using the two-dimensional array.

                                  In this program, we will print a matrix that has two rows and three columns. And we have used for loop for printing Matrix.

#include<stdio.h>
#include<conio.h>
void main()
{
   int m[2][3],i,j;
   clrscr();
   printf("Enter array elements for(2*3) matrix :\n");
      for(i=0;i<2;i++)
      {
          for(j=0;j<3;j++)
           {
           scanf("%d",&m[i][j]);
           }
      }
   printf("The given Matrix is :\n");
      for(i=0;i<2;i++)
      {
          for(j=0;j<3;j++)
           {
           printf(" %d",m[i][j]);
           }
           printf("\n");
      }
   getch();
}

============================

OUTPUT:-

Enter array elements for(2*3) matrix :
1 2 3 5 6 7                                                                    
The given Matrix is :                                                          
 1 2 3                                                                         
 5 6 7  

============================                                                                     
     
C program to print matrix by using two-dimensional array
    

Comments