This C Program finds the transpose of a given matrix. The transpose of a given matrix is formed by interchanging the rows and columns of a matrix.

Here is source code of the C program to find the transpose of a given matrix .The C program is successfully compiled and run on a Linux system. The program output is also shown below.

`/*`

`* C program to accept a matrix of order MxN and find its transpose`

`*/`

`#include <stdio.h>`

void main()

`{`

static int array[10][10];

int i, j, m, n;

printf("Enter the order of the matrix \n");

scanf("%d %d", &m, &n);

printf("Enter the coefiicients of the matrix\n");

for (i = 0; i < m; ++i)

`{`

for (j = 0; j < n; ++j)

`{`

scanf("%d", &array[i][j]);

`}`

`}`

printf("The given matrix is \n");

for (i = 0; i < m; ++i)

`{`

for (j = 0; j < n; ++j)

`{`

printf(" %d", array[i][j]);

`}`

printf("\n");

`}`

printf("Transpose of matrix is \n");

for (j = 0; j < n; ++j)

`{`

for (i = 0; i < m; ++i)

`{`

printf(" %d", array[i][j]);

`}`

printf("\n");

`}`

`}`

$ cc pgm85.c $ a.out Enter the order of the matrix 3 3 Enter the coefiicients of the matrix 3 7 9 2 7 5 6 3 4 The given matrix is 3 7 9 2 7 5 6 3 4 Transpose of matrix is 3 2 6 7 7 3 9 5 4

If you wish to look at other example programs on Matrix, go to C Programming Examples on Matrix. If you wish to look at programming examples on all topics, go to C Programming Examples.