Transpose of a matrix is obtained by changing rows to columns and columns to rows. In other words, transpose of A[][] is obtained by changing A[i][j] to A[j][i].

## C Program to Find Transpose of a Matrix

```	```
#include <stdio.h>
int main() {
int a, transpose, r, c;
printf("Enter rows and columns: ");
scanf("%d %d", &r, &c);

printf("\nEnter matrix elements:\n");
for (int i = 0; i < r; ++i)
for (int j = 0; j < c; ++j) {
printf("Enter element a%d%d: ", i + 1, j + 1);
scanf("%d", &a[i][j]);
}

printf("\nEntered matrix: \n");
for (int i = 0; i < r; ++i)
for (int j = 0; j < c; ++j) {
printf("%d  ", a[i][j]);
if (j == c - 1)
printf("\n");
}

for (int i = 0; i < r; ++i)
for (int j = 0; j < c; ++j) {
transpose[j][i] = a[i][j];
}

printf("\nTranspose of the matrix:\n");
for (int i = 0; i < c; ++i)
for (int j = 0; j < r; ++j) {
printf("%d  ", transpose[i][j]);
if (j == r - 1)
printf("\n");
}
return 0;
}
```
```

Output :

```	```
Enter rows and columns: 3
4

Enter matrix elements:
Enter element a11: 1
Enter element a12: 2
Enter element a13: 3
Enter element a14: 4
Enter element a21: 5
Enter element a22: 6
Enter element a23: 7
Enter element a24: 8
Enter element a31: 9
Enter element a32: 10
Enter element a33: 11
Enter element a34: 12

Entered matrix:
1  2  3  4
5  6  7  8
9  10  11  12

Transpose of the matrix:
1  5  9
2  6  10
3  7  11
4  8  12
```
```