My photo
Bangalore, Karnataka, India
Extending one hand to help someone has more value rather than joining two hands for prayer

Archives

program to find the transpose of a matrix

Tuesday, September 1, 2009

#include<iostream.h>
#include<conio.h>
void main()
{
 clrscr();
 int x[10][10],m,n;
 cout<<"number of rows and columns"<<endl;
 cin>>m>>n;
 cout<<"enter the elements: ";
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
cin>>x[i][j];
cout<<"matrix is: "<<endl;
for(i=0;i<m;i++)
{  for(j=0;j<n;j++)
   cout<<x[i][j]<<"\t";
   cout<<endl;
 }
 cout<<endl<<endl<<endl<<endl;
 cout<<"transpose of this matrix is: "<<endl;
 for(j=0;j<n;j++)
 { for(i=0;i<m;i++)
   cout<<x[i][j]<<"\t";
   cout<<endl;
 }
 getch();
 }

0 comments: