- #include<iostream.h>
- #include<conio.h>
- void main()
- {
- clrscr();
- int a[10][10],m,n,i,j;
- cout<<"Enter number of rows: ";
- cin>>m;
- cout<<"Enter number of coloumns: ";
- cin>>n;
- //Coding by:Mir Mueen
- //http://www.thecorblog.blogspot.com
- if(m!=n)
- {
- cout<<"Matrix not square so Transpose not possible :(";
- }
- else
- {
- cout<<endl<<"Enter elements of matrix: "<<endl;
- for(i=0;i<m;i++)
- {
- for(j=0;j<n;j++)
- {
- cout<<"Enter element a"<<i+1<<j+1<<": ";
- cin>>a[i][j];
- }
- }
- cout<<endl<<"Displaying Matrix: "<<endl<<endl;
- for(i=0;i<m;i++)
- {
- for(j=0;j<n;j++)
- {
- cout<<a[i][j]<<" ";
- }
- cout<<endl<<endl;
- }
- cout<<endl<<"Displaying Matrix Transpose: "<<endl<<endl;
- for(i=0;i<m;i++)
- {
- for(j=0;j<n;j++)
- {
- cout<<a[j][i]<<" ";
- }
- cout<<endl<<endl;
- }
- }
- getch();
- }
Tuesday, April 9, 2013
Tranpose of matrix in c++
Subscribe to:
Posts (Atom)