- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
To transpose any matrix in C++ Programming language, you have to first ask to the user to enter the matrix and replace row by column and column by row to transpose that matrix, then display the transpose of the matrix on the screen as shown here in the following C++ program
Source Code: Transpose of a Matrix
/* C++ Program - Transpose Matrix */ #include<iostream.h> #include<conio.h> void main() { clrscr(); int arr[3][3], i, j, arrt[3][3]; cout<<"Enter 3*3 Array Elements : "; for(i=0; i<3; i++) { for(j=0; j<3; j++) { cin>>arr[i][j]; } } cout<<"Transposing Array...\n"; for(i=0; i<3; i++) { for(j=0; j<3; j++) { arrt[i][j]=arr[j][i]; } } cout<<"Transpose of the Matrix is :\n"; for(i=0; i<3; i++) { for(j=0; j<3; j++) { cout<<arrt[i][j]; } cout<<"\n"; } getch(); }Output
Enter 3*3 Array Elements : 1 2 3 4 5 6 7 8 9 Transposing Array... Transpose of the Matrix is : 1 4 7 2 5 8 3 6 9