C++ Programming Code Examples C++ > Arrays and Matrices Code Examples programs to find transpose of a matrix with function and without function programs to find transpose of a matrix with function and without function Write two C++ programs which asks user to enter number of rows and colums and calculate its transpose and display the result accordingly. Note: One with function and one without Function function prototype: void calculate_transpose(int matrix[5][5], int rows, int cols); First we have to clear about what is transpose of a matrix. Its to replace the number of rows with number of colums and vice versa to make a new matrix. for example if a matrix 'A' has dimension 2X3 means 2 rows 3 colums then new transpose matrix 'T' will be 3X2 1 2 3 1 4 A= 4 5 6 T= 2 5 3 6 #include<iostream> using namespace std; int main() { int matrix[5][5],transpose_matrix[5][5]; int i,j,rows,cols; // Taking Input In Array cout<<"Enter Number of ROWS :"; cin>>rows; cout<<"Enter Number Of COLS :"; cin>>cols; for( i=0;i<rows;i++){ for( j=0;j<cols;j++) { cin>>matrix[i][j]; } } cout<<"\n Matrix You Entered\n"; for( i=0;i<rows;i++){ for( j=0;j<cols;j++) { cout<<matrix[i][j]<<" "; } cout<<endl; } // Calculating Transpose of Matrix cout<<"\n\n\nTranspose of Entered Matrix\n"; for( i=0;i<rows;i++){ for( j=0;j<cols;j++) { transpose_matrix[j][i]=matrix[i][j]; } cout<<endl; } //Displaying Final Resultant Array for( i=0;i<cols;i++){ for( j=0;j<rows;j++) { cout<<transpose_matrix[i][j]<<" "; } cout<<endl; } return 0; }