Program to read and print matrix.
Solution in C PYTHON
#include<stdio.h>
int main() {
int mtrx[10][10], rows, cols, i, j;
//Read size of matrix
scanf("%d %d",&rows,&cols);
//Read rows*cols elements for matrix
for(i=0;i<rows;i++)
for(j=0;j<cols;j++)
scanf("%d",&mtrx[i][j]);
//Print given matrix
for(i=0;i<rows;i++){
for(j=0;j<cols;j++){
printf("%d ",mtrx[i][j]);
}
printf("\n");
}
return 0;
}
int main() {
int mtrx[10][10], rows, cols, i, j;
//Read size of matrix
scanf("%d %d",&rows,&cols);
//Read rows*cols elements for matrix
for(i=0;i<rows;i++)
for(j=0;j<cols;j++)
scanf("%d",&mtrx[i][j]);
//Print given matrix
for(i=0;i<rows;i++){
for(j=0;j<cols;j++){
printf("%d ",mtrx[i][j]);
}
printf("\n");
}
return 0;
}
Input
3 3
1 2 3
4 5 6
7 8 9
Output
1 2 3
4 5 6
7 8 9
3 3
1 2 3
4 5 6
7 8 9
Output
1 2 3
4 5 6
7 8 9