#include <stdio.h>
int main()
{
int mat1[10][10], mat2[10][10];
int i, j, n, row, col;
printf("Enter the number of rows(0-10):");
scanf("%d", &row);
printf("Enter the number of columns(0-10):");
scanf("%d", &col);
/* get the entries for the input matrix */
printf("Enter your entries for the input matrix:\n");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
scanf("%d", &mat1[i][j]);
}
}
/* copy the contents in input matrix to output matrix */
for (i = 0; i < row; i++) {
for (j = 0; j < col; j++) {
mat2[i][j] = mat1[i][j];
}
}
/* print the contents in the output matrix */
printf("Contents in the output matrix:\n");
for (i = 0; i < row; i++) {
for (j = 0; j < col; j++) {
printf("%d ", mat1[i][j]);
}
printf("\n");
}
return 0;
}
int main()
{
int mat1[10][10], mat2[10][10];
int i, j, n, row, col;
printf("Enter the number of rows(0-10):");
scanf("%d", &row);
printf("Enter the number of columns(0-10):");
scanf("%d", &col);
/* get the entries for the input matrix */
printf("Enter your entries for the input matrix:\n");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
scanf("%d", &mat1[i][j]);
}
}
/* copy the contents in input matrix to output matrix */
for (i = 0; i < row; i++) {
for (j = 0; j < col; j++) {
mat2[i][j] = mat1[i][j];
}
}
/* print the contents in the output matrix */
printf("Contents in the output matrix:\n");
for (i = 0; i < row; i++) {
for (j = 0; j < col; j++) {
printf("%d ", mat1[i][j]);
}
printf("\n");
}
return 0;
}
OUTPUT:
Enter the number of rows(0-10):3
Enter the number of columns(0-10):3
Enter your entries for the input matrix:
5
6
7
2
3
1
9
8
0
Contents in the output matrix:
5 6 7
2 3 1
9 8 0
0 Comments:
Post a Comment