Showing posts with label Matrix Transpose. Show all posts
Showing posts with label Matrix Transpose. Show all posts

Wednesday, July 6, 2011

Program to find the transpose of the given Matrix


#include<iostream.h>
#include<conio.h>
void main()
{
  clrscr();
  int m[10][10];
  int i,j,r,c;
  for (i=0;i<10;i++)
  {
    for (j=0;j<10;j++)
    {
      m[i][j]=0;
    }
  }
  cout<<" Enter size of row and colomn:"<<endl;
  cin>>r>>c;
  cout<<" Enter the two matrices:"<<endl;
  for (i=0;i<r;i++)
  {
    for (j=0;j<c;j++)
    {
      cout<<"Enter element of m1: "<<(i+1)<<(j+1);
      cin>>m[i][j];
    }
  }
  cout<<" The matrix is: "<<endl;
  for (i=0;i<r;i++)
  {
    for (j=0;j<c;j++)
    {
      cout<<m[i][j];
    }
    cout<<"\n";
  }
  cout<<" The transpose of the matrix is: "<<endl;
  for (i=0;i<r;i++)
  {
    for (j=0;j<c;j++)
    {
      cout<<m[j][i];
    }
    cout<<"\n";
  }
  getch();
}