Transpose Of A Matrix in C++

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[10][10];
int b[10][10];
int row=0,col=0,i,j;
cout<<"\n Enter No of Rows And Colomn: ";
cin>>row>>col;
cout<<"\n Enter the values in matrix: (row by row) ";
for(i=1;i<=row;i++){
for(j=1;j<=col;j++){
cin>>a[i][j];
}}
for(i=1;i<=row;i++){
cout<<endl;
for(j=1;j<=col;j++){
cout<<a[i][j]<<"  \t";
}
}
for(i=1;i<=col;i++){
for(j=1;j<=row;j++){
b[j][i]=a[i][j];
} }
cout<<endl;
cout<<"\n Transpose Of The Matrix You Enter:-\n";
for(i=1;i<=row;i++){
cout<<endl;
for(int j=1;j<=col;j++){
cout<<b[i][j]<<"  \t";
}
}
getch();
      }

Another Screen Short of Code in C.



No comments

Powered by Blogger.