MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

Matrix/MatrixTranspose.cpp:4–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2using namespace std;
3
4int main() {
5 int a[10][10], transpose[10][10], row, column, i, j;
6
7 cout << "Enter rows and columns of matrix: ";
8 cin >> row >> column;
9
10 cout << "\nEnter elements of matrix: " << endl;
11
12 for (int i = 0; i < row; ++i) {
13 for (int j = 0; j < column; ++j) {
14 cout << "Enter element a" << i + 1 << j + 1 << ": ";
15 cin >> a[i][j];
16 }
17 }
18
19 cout << "\nEntered Matrix: " << endl;
20 for (int i = 0; i < row; ++i) {
21 for (int j = 0; j < column; ++j) {
22 cout << " " << a[i][j];
23 if (j == column - 1)
24 cout << endl << endl;
25 }
26 }
27
28 for (int i = 0; i < row; ++i)
29 for (int j = 0; j < column; ++j) {
30 transpose[j][i] = a[i][j];
31 }
32
33 cout << "\nTranspose of Matrix: " << endl;
34 for (int i = 0; i < column; ++i)
35 for (int j = 0; j < row; ++j) {
36 cout << " " << transpose[i][j];
37 if (j == row - 1)
38 cout << endl << endl;
39 }
40
41 return 0;
42}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected