forked from HemangTheHuman/hacktoberfest-2022
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatrix_transpose.cpp
More file actions
35 lines (35 loc) · 789 Bytes
/
matrix_transpose.cpp
File metadata and controls
35 lines (35 loc) · 789 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
31
32
33
34
35
# include <iostream>
using namespace std;
int main()
{
int i, j, n, m, a[10][10];
cout << "Enter the number of rows and columns of the matrix: ";
cin >> n >> m;
cout << "Enter the elements of the matrix: ";
for (i = 0; i < n; i++)
{
for (j = 0; j < m; j++)
{
cin >> a[i][j];
}
}
cout << "The matrix is: " << endl;
for (i = 0; i < n; i++)
{
for (j = 0; j < m; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
cout << "The transpose of the matrix is: " << endl;
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
cout << a[j][i] << " ";
}
cout << endl;
}
return 0;
}