Menu BAR

FEEL FREE TO ASK ANY PROGRAM and please mention any error if you find it

8 Apr 2013

TO PRINT TRANSPOSE OF A MATRIX IN C++


Write a program to print transpose of a matrix in c++

#include<iostream.h>
#include<conio.h>
void main()
{
 clrscr();
 int a[10][10];
 int i, j, n, m;
 int x[100],y[100];
 cout<<"enter no of rows\n";
 cin>>n;
 cout<<"enter no of colomn\n";
 cin>>m;
 cout<<"enter the elements of matrix\n";
 for(i=0;i<n;i++)
  {
   for(j=0;j<m;j++)
    {
     cout<<"a["<<i+1<<"]["<<j+1<<"]:= ";
     cin>>a[i][j];
    }

  }
 cout<<"matrix u have entered is"<<endl;
 for(i=0;i<n;i++)
  {
   for(j=0;j<m;j++)
    {
     cout<<"\t"<<a[i][j];
    }
    cout<<endl;
  }
  cout<<"\n\ntranspose of matrix is:="<<endl;
  for(j=0;j<m;j++)
  {
   for(i=0;i<n;i++)
    {
     cout<<"\t"<<a[i][j];
    }
    cout<<endl;
  }
getch();
}

==OUTPUT==


No comments:

Post a Comment