0% found this document useful (0 votes)
21 views

Q 12. WAP To Declare A Class Transpose Which Transpose The Elements of Entered Matrix

The document defines a class called "transpose" that takes a 2D matrix as input from the user, stores it, and then outputs the transposed matrix by swapping the row and column indexes when printing the elements. It takes the matrix size as input, stores the entered elements, prints the original matrix, and then prints the transposed matrix.

Uploaded by

Swapnil Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Q 12. WAP To Declare A Class Transpose Which Transpose The Elements of Entered Matrix

The document defines a class called "transpose" that takes a 2D matrix as input from the user, stores it, and then outputs the transposed matrix by swapping the row and column indexes when printing the elements. It takes the matrix size as input, stores the entered elements, prints the original matrix, and then prints the transposed matrix.

Uploaded by

Swapnil Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Q 12.

WAP to declare a class transpose which transpose the elements of


entered matrix .

#include<iostream.h>
#include<conio.h>
class transpose
{
public:
void getdata();
};
void transpose::getdata()
{
int x[10][10],c,r,i,j;
cout<<"Enter rows limit : ";
cin>>r;
cout<<"Enter column limit : ";
cin>>c;
cout<<"Enter matrix : \n";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cin>>x[i][j];
}
}
cout<<"Entered matrix is :\n";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cout<<x[i][j]<<" ";
}
cout<<endl;
}
cout<<"After transpose matrix is :\n";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cout<<x[j][i]<<" ";
}
cout<<endl;
}
}
void main()
{
clrscr();
transpose t;
t.getdata();
getch();
}

OUTPUT 12 :

Enter rows limit : 3


Enter column limit : 3
Enter matrix :
1
2
3
4
5
6
7
8
9
Entered matrix is :
1 2 3
4 5 6
7 8 9
After transpose matrix is :
1 4 7
2 5 8
3 6 9

You might also like