forked from tun-eer/hacktoberfest2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransposeofamatrix.cpp
50 lines (49 loc) · 937 Bytes
/
transposeofamatrix.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
int main()
{
int a[10][10],transpose[10][10],row,column,i,j;
cout<<"enter the number of rows and columns:";
cin>>row>>column;
cout<<"\nenter the rows and columns of matrix:" <<endl;
//ENTERING THE MATRIX
for(i=0; i<row; ++i)
{
for(j=0;j<column;++j)
{
cout<< " enter element a" <<i+1<<j+1<<":";
cin>>a[i][j];
}
}
//DISPLAYING THE ENTERED MATRIX
cout<<"entered matrix:" <<endl;
for(int i=0; i<row; ++i)
{
for(j=0;j<column;++j)
{
cout<< " "<<a[i][j];
if(j==column-1)
cout<<endl<<endl;
}
}
//TRANSPOSE OF THE ROWS AND COLUMNS
for(i=0;i<row;++i)
{
for(j=0;j<column;++j)
{
transpose[j][i]= a[i][j];
}
}
//DISPLAYING THE TRANSPOSE
cout<<"transpoe of matrix:";
for( i=0;i<row;++i)
{
for(j=0;j<column;++j)
{
cout<< " "<<transpose[i][j];
if(j == row-1)
cout<< endl <<endl;
}
}
return 0;