forked from abhijithshaji17/cpp-mastery
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path17.cpp
More file actions
30 lines (30 loc) · 651 Bytes
/
Copy path17.cpp
File metadata and controls
30 lines (30 loc) · 651 Bytes
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
// transpose matrix
#include<iostream>
using namespace std;
int main(){
int a[10][10],m,n,i,j;
cout<<"Enter the no. of rows and columns of matrix: ";
cin>>m>>n;
cout<<"Enter matrix elements:\n";
for(i=0;i<m;i++){
for(j=0;j<n;j++){
cout<<"Element "<<i+1<<": ";
cin>>a[i][j];
}
}
cout<<"\nMatrix:\n";
for(i=0;i<m;i++){
for(j=0;j<n;j++){
cout<<a[i][j]<<"\t";
}
cout<<"\n";
}
cout<<"\nTranspose Matrix:\n";
for(i=0;i<n;i++){
for(j=0;j<m;j++){
cout<<a[j][i]<<"\t";
}
cout<<"\n";
}
return 0;
}