Skip to main content

Featured

functions in Python

C program to print transpose matrix


//C++ program to print transpose of a matrix
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int matrix[3][4],transpose_matrix[4][3];
int i,j;
cout<<"\nEnter numbers to fill matrix\n";
for(i=0;i<3;i++)
{
  for(j=0;j<4;j++)
  {
   cin>>matrix[i][j];
   transpose_matrix[j][i]=matrix[i][j];
  }
}
cout<<"Original Matrix:\n";
for(i=0;i<3;i++)
{
  for(j=0;j<4;j++)
  {
   cout<<matrix[i][j]<<" ";
  }
 cout<<"\n";
}
cout<<"\n\nTranspose of Matrix:\n";

for(i=0;i<4;i++)
{
  for(j=0;j<3;j++)
  {
   cout<<transpose_matrix[i][j]<<" ";
  }
cout<<"\n";
}

getch();
}

Comments

Popular Posts