Write a C Program Program to input and display a matrix
#define ROW 3
#define COL 4
#include<stdio.h>
int main(void)
{
int mat[ROW][COL],i,j;
printf("Enter the elements of the matrix(%dx%d) row-wise :\n",ROW,COL);
for(i=0; i<ROW; i++)
for(j=0; j<COL; j++)
scanf("%d",&mat[i][j]);
printf("The matrix that you have entered is :\n");
for(i=0; i<ROW; i++)
{
for(j=0; j<COL; j++)
printf("%5d",mat[i][j]);
printf("\n");
}
printf("\n");
return 0;
}
Output
Enter the elements of the matrix(3x4) row-wise :
12 13 14 15
16 17 18 19
20 21 22 23
The matrix that you have entered is :
12 13 14 15
16 17 18 19
20 21 22 23