C PROGRAM TO TRANSPOSE THE GIVEN MATRIX:
EX:
enter the no. of rows and columns of matrix
3 3
enter the elements in the matrix
1 2 3
4 5 6
7 8 9
THE TRANSPOSED MATRIX IS
1 4 7
2 5 8
3 6 9
PROGRAM:
#include <stdio.h>
int main()
{
int i,j,m,n;
printf("enter the no.of rows and columns");
scanf("%d%d",&m,&n);
int a[m][n];
printf("enter the elements in the matrix");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("the transposed matrix is");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",a[j][i]);
}
printf("\n");
}
return 0;
}
LEARN WITH JAGADEESH
copyright© to jagadeesh
Post a Comment