From 8cb4056e63e3dba34bab466830307a7965a3c1f3 Mon Sep 17 00:00:00 2001 From: Aviral Srivastava <63746541+Aviral-3@users.noreply.github.com> Date: Sat, 23 Oct 2021 16:57:53 +0530 Subject: [PATCH] Transpose of a matrix This program takes a matrix of request m * n from the user and figures out the transpose of matrix. --- Transpose of a Matrix.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Transpose of a Matrix.cpp diff --git a/Transpose of a Matrix.cpp b/Transpose of a Matrix.cpp new file mode 100644 index 0000000..6c4864e --- /dev/null +++ b/Transpose of a Matrix.cpp @@ -0,0 +1,28 @@ +#include +using namespace std; + +int main() { + int a[10][10], transpose[10][10], row, column, i, j; + + cout << "Enter rows and columns of matrix: "; + cin >> row >> column; + + cout << "\nEnter elements of matrix: " << endl; + + // Storing matrix elements + for (int i = 0; i < row; ++i) { + for (int j = 0; j < column; ++j) { + cout << "Enter element a" << i + 1 << j + 1 << ": "; + cin >> a[i][j]; + } + } + + // Printing the a matrix + cout << "\nEntered Matrix: " << endl; + for (int i = 0; i < row; ++i) { + for (int j = 0; j < column; ++j) { + cout << " " << a[i][j]; + if (j == column - 1) + cout << endl << endl; + } + } \ No newline at end of file