# Program to obtain Transpose of a Matrix

A transpose of a matrix is formed by turning all the rows of a given matrix into columns and vice-versa. The transpose of matrix A is written as AT Below is the program that will obtain transpose of 3 by 3 matrix. This program takes arr matrix as input. It will then display its transpose matrix arrT.

```#include
#include
void main(){
int arr, arrT;
int i,j;
clrscr();
printf("Enter the 3x3 matrix:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("Enter the element arr[%d][%d] : ",i,j);
scanf("%d",&arr[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
arrT[j][i] = arr[i][j];
}
}
printf("The transpose of the matrix is: \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\t%d",arrT[i][j]);
}
printf("\n");
}
getch();
}
```

Output:

```Enter the 3x3 matrix:
Enter the element arr : 1
Enter the element arr : 2
Enter the element arr : 3
Enter the element arr : 4
Enter the element arr : 5
Enter the element arr : 6
Enter the element arr : 7
Enter the element arr : 8
Enter the element arr : 9
The transpose of the matrix is:
1       4       7
2       5       8
3       6       9```

### 5 Responses

1. Anonymous says:

Good

2. Anonymous says:

This makes sense, I approve!

3. Anonymous says:

i think that it is a very good site to learn programming

1. March 1, 2014

[…] symmetric matrix is a square matrix that is equal to its transpose. Let A be a symmetric matrix. Then, A = […]

2. March 1, 2014

[…] Program to obtain Transpose of a Matrix […]