Program to Calculate Transpose of A Matrix:
#include<iostream>
using namespace std;
main()
{
int a[10][10],b[10][10],m,n,i,j;
cout<<"\nEnter The Order Of Matrix\n";
cin>>m>>n;
cout<<"Enter The Elements Rowwise";
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<"\na["<<i<<"]["<<j<<"] =";
cin>>a[i][j];
}
}
cout<<"\nTranspose is\n";
for(i=0;i<m;i++)
{for(j=0;j<n;j++)
b[j][i]=a[i][j];
}
for(i=0;i<n;i++)
{ cout<<"\n";
for(j=0;j<m;j++)
{
cout<<b[i][j]<<"\t";
}
}
}
#include<iostream>
using namespace std;
main()
{
int a[10][10],b[10][10],m,n,i,j;
cout<<"\nEnter The Order Of Matrix\n";
cin>>m>>n;
cout<<"Enter The Elements Rowwise";
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<"\na["<<i<<"]["<<j<<"] =";
cin>>a[i][j];
}
}
cout<<"\nTranspose is\n";
for(i=0;i<m;i++)
{for(j=0;j<n;j++)
b[j][i]=a[i][j];
}
for(i=0;i<n;i++)
{ cout<<"\n";
for(j=0;j<m;j++)
{
cout<<b[i][j]<<"\t";
}
}
}