C++ Program to Compute Transpose of Matrix
Write C++ Program to Compute Transpose of Matrix
// CPP Program to Compute Transpose of Matrix #include <iostream> using namespace std; int main() { int A[3][3]={ {2, 1, 6}, {9, 5, 1}, {4, 3, 8} }; int i, j; cout << "Matrix A :--> \n"; for(i = 0;i < 3; i++) { for( j = 0; j < 3; j++) { cout << A[i][j] << " "; } cout << endl; } cout << "\nTranspose of Matrix A :--> \n"; for(i = 0; i < 3; i++) { for(j = 0; j < 3; j++) { cout << A[j][i] << " "; } cout << endl ; } return 0; }
Output:
Matrix A :-->
2 1 6
9 5 1
4 3 8
Transpose of Matrix A :-->
2 9 4
1 5 3
6 1 8