Code:
#include iostream
#include conio.h
#include stdio.h
using namespace std;
int main()
{
int i, j, n;
int a[10][10] = {0},b[10][10] = {0};
cout<<"Enter the order of matrix ";
cin>>n;
cout<<"Enter the elements\n";
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n; j++)
{
cin>>a[i][j];
}
}
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n; j++)
{
b[j][i] = a[i][j];
}
}
cout<
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n; j++)
{
cout<
}
cout<
}
cout<
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n; j++)
{
cout<
}
cout<
}
getch();
}
Output:
Enter the order of matrix 3
Enter the elements
5
3
1
8
6
9
4
7
0
Original Matrix
5 3 1
8 6 9
4 7 0
Transpose Matrix
5 8 4
3 6 7
1 9 0
More C++ Programs: