C++ Programming Code Examples C++ > Arrays and Matrices Code Examples Programming Code to Transpose Matrix Programming Code to Transpose Matrix 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. Following C++ program ask to the user to enter any 3*3 array/matrix element to transpose and display the transpose of the matrix on the screen: /* 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(); }