Tuesday 17 January 2012

matrix transpose


#include<iostream.h>
#include<conio.h>
void main()
{
int mat[3][3],matt[3][3],i,j;
clrscr();
cout<<"Enter the elements in the matrix"<<endl;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>mat[i][j];
}
}
//loop to transpose a matrix
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
matt[i][j]=mat[j][i];
}
}

cout<<"The Transpose matrix is "<<endl;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<matt[i][j]<<"\t";
}
cout<<endl;

}
getch();
}

No comments:

Post a Comment