# How to Find Transpose of a Matrix in C++

We are going to learn about How to Find Transpose of a Matrix in C++. We will take the input from the user for the matrix elements and then perform the Transpose operation on the matrix.

### 1. How to Find Transpose of a Matrix in C++

In this example, we are going to do the Transpose of a given Matrix. We will ask the user to enter the values for each index, and once we have the matrices, then we will Transpose the matrix by rotating the rows and column elements. let us understand this with the help of the below code example.

### How to Find Transpose of a Matrix in C++ Program

```#include<iostream>
using namespace std;
int main()
{
int Matrix;
int RowSize , ColumnSize;
int row, col;

cout<<"Enter Row and Column Size of the Matrix: ";
cin>>RowSize>>ColumnSize;

cout<<"Please enter the Elements of the Matrix: ";
for(row=0; row< RowSize; row++)
{
for(col=0; col< ColumnSize; col++)
cin>> Matrix[row][col];
}

cout<<"The inputted Matrix is: ";
for(row=0; row< RowSize; row++)
{
for(col=0; col< ColumnSize; col++)
cout<<Matrix[row][col];
cout<<"\n";
}

cout<<"The Transpose of the Matrix is:\n";

for(col=0; col< ColumnSize; col++)
{
for(row=0; row< RowSize; row++)
cout<<Matrix[row][col];
cout<<"\n";
}
return 0;
}
```

Output

```Enter Row and Column Size of the Matrix: 3
3
Please enter the Elements of the Matrix: 1
2
3
4
5
6
7
8
9
The inputted Matrix is: 123
456
789
The Transpose of the Matrix is:
147
258
369
```