## Sep 30, 2011

### C program to find the transpose of a given Matrix.

Write a C program to read A (MxN), find the transpose of a given matrix and output both the input matrix and the transposed matrix.
Transpose of a matrix is the interchanging the rows and columns, If A is matrix of order(i*j), where i is the row and j is the column, then Transpose of A is A(j*i). Read more about C Programming Language .

```/***********************************************************
* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact info@c-program-example.com
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
*                                  Happy Coding
***********************************************************/

*/

#include <stdio.h>
#include <conio.h>

void main()
{
int i,j,M,N;
int A[10][10], B[10][10];

int transpose(int A[][10], int r, int c);  /*Function prototype*/

clrscr();

printf("Enter the order of matrix A\n");
scanf("%d %d", &M, &N);

printf("Enter the elements of matrix\n");
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
scanf("%d",&A[i][j]);
}
}

printf("Matrix A is\n");
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
printf("%3d",A[i][j]);
}
printf("\n");
}

/* Finding Transpose of matrix*/
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
B[i][j] =  A[j][i];
}
}

printf("Its Transpose is\n");
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
printf("%3d",B[i][j]);
}
printf("\n");
}

}  /*End of main()*/```
```Read more Similar C Programs
Matrix Programs
Learn C Programming```
You can easily select the code by double clicking on the code area above.