# Write a program that transposes a matrix A and displays result on the screen.

Note: A matrix which is obtained by the interchanging of rows and columns of a matrix is called the transpose of given matrix and is denoted by At.

**So let’s Write Code:**

**Write a program that transposes a matrix A and displays the result on the screen | Transpose of a Matrix.**

```
#include<iostream.h>
using namespace std;
void transpose(int [2][4], int [4][2]);
void print(char [25], int [4][2]);
main()
{
int A[2][4]={{24,31,18,51},{4,15,13,2}};
int T[4][2];
char str[25];
cout<<endl<<"Matrix A:"<<endl;
for(int r = 0; r<=1; r++)
{
for(int c = 0; c<=3; c++)
cout<<A[r][c]<<"\t";
cout<<endl;
}
transpose(A, T);
print("Transpose of A: ",T);
}
// definition of transpose() function
void transpose(int X[2][4], int Y[4][2])
{
int r, c;
for(r = 0; r<=1; r++)
for(c = 0; c<=3; c++)
Y[c][r] = X[r][c];
}
void print(char str[], int R[4][2])
{
int r, c;
cout<<endl<<str<<endl;
for(r = 0; r<=3; r++)
{
for(c = 0; c<=1; c++)
cout<<R[r][c]<<"\t";
cout<<endl;
}
}
```

**Hope You will learn Something. Happy Coding.**

###### Visit my YouTube Channel as Well๐ https://www.youtube.com/watch?v=JuIHQ9cLSEw&list=PLbIhkHxfUIItTdcyCb34uRIrPJbXBndIl&index=4

**Click on the below Links for more Programming Exercises: **

**Conditional Structure Exercises: **๐https://myustaadg.com/category/programming-exercises/conditional-structures-exercises/

**Array Exercises: ๐**https://myustaadg.com/category/programming-exercises/arrays-exercises/