A program to explain find transpose of matrix
C Programming Language 062
The following code shows how to write a program to explain find transpose of matrix.
Program
#include <stdio.h>
void main()
{
int a[10][10], m, n, i, j, t[10][10];
printf("Enter order m,n [m x n]: ");
scanf("%d %d", &m, &n);
printf("Enter values:\n");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
scanf("%d", &a[i][j]);
}
}
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
t[j][i] = a[i][j];
}
}
printf("Transpose is:\n");
for (i = 0; i < n; i++)
{
for (j = 0; j < m; j++)
{
printf("%d\t", t[i][j]);
}
printf("\n");
}
printf("\n");
}
Result
Enter order m,n [m x n]: 2 3
Enter values:
1 2 3
4 5 6
Transpose is:
1 4
2 5
3 6
Last Updated on
Comments