PROGRAM TO FIND TRANSPOSE OF A MATRIX

/*PROGRAM TO FIND TRANSPOSE OF A MATRIX*/

#include<conio.h>

#include<iostream.h>

class transpose

{

int m,n,i,j,k,a[5][5];

public:

void input();

void output();

};

void transpose::input()

{

cout<<“Enter order of the matrix: “;

cin>>m>>n;

cout<<“Enter “<<m*n<<” elements in the matrix:\n”;

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

cin>>a[i][j];

}

}

void transpose::output()

{

cout<<“Before transpose the matrix is: \n”;

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

cout<<a[i][j]<<”   “;

cout<<endl;

}

cout<<“After transpose the given matrix is:\n”;

for(i=0;i<n;i++)

{

for(j=0;j<m;j++)

cout<<a[j][i]<<”   “;

cout<<endl;

}

}

void main()

{

transpose t1;

clrscr();

t1.input();

t1.output();

getch();

}

Leave a Reply

Your email address will not be published. Required fields are marked *