#include <stdio.
h>
C program to transpose a int main()
{
matrix int m, n, c, d, matrix[10][10], transpose[10]
[10];
This c program prints transpose of a matrix. It is obtained by printf("Enter the number of rows and columns of
interchanging rows and columns of a matrix. For example if a matrix\n");
matrix is scanf("%d%d", &m, &n);
12 printf("Enter the elements of matrix\n");
34
56 for (c = 0; c < m; c++)
for(d = 0; d < n; d++)
then transpose of above matrix will be
scanf("%d",&matrix[c][d]);
135
246 for (c = 0; c < m; c++)
for( d = 0 ; d < n ; d++ )
When we transpose a matrix then the order of matrix changes,
transpose[d][c] = matrix[c][d];
but for a square matrix order remains same.
printf("Transpose of entered matrix :-\n");
for (c = 0; c < n; c++) {
for (d = 0; d < m; d++)
printf("%d\t",transpose[c][d]);
printf("\n");
}
return 0;
}