/********************************************
* Program to find the transpose of a matrix
********************************************/
#include<stdio.h> // include stdio.h
#define ROW 2
#define COL 4
int main()
{
int i, j, mat[ROW][COL], trans_mat[COL][ROW];
printf("Enter matrix: \n");
// input matrix
for(i = 0; i < ROW; i++)
{
for(j = 0; j < COL; j++)
{
scanf("%d", &mat[i][j]);
}
}
/* create transpose matrix by
* switch entries
*/
for(i = 0; i < ROW; i++)
{
for(j = 0; j < COL; j++)
{
trans_mat[j][i] = mat[i][j];
}
}
printf("\nTranspose matrix: \n");
// print transpose matrix
for(i = 0; i < COL; i++)
{
for(j = 0; j < ROW; j++)
{
printf("%d ", trans_mat[i][j]);
}
printf("\n");
}
// signal to operating system everything works fine
return 0;
}