A matrix is taken from user.. and its Transpose is displayed as output..
Select To use this code as it is.. select and copy paste this code into code.cpp file :)
- #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: Snehil Khanor
- //http://WapCPP.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();
- }
13 comments:
thanks for this code understanding
by doing lot of efforts i have have founded a blog related to my blog topic................visit my blog http://cpp-programs.blogspot.com/
thanks
hi..dear
my self rizwan
i am interested in cpp...so much
i get a very impress by ur codind.and i also applied it in my programming..insha allah...thanx
thanks for this code understanding
Transpose isn't meant to be used for square matrix only. The matrix can be of any size, be it 2X3, 5X2 etc. (Then it's transpose matrix will be of size 3X2, 2X5 ).
transpose is also possible even if rows and columns are not equal, i.e, mXn matrix becomes nXm
i just dnt understand CP
why is it compulsory in FE
scrap................!!!!!!!!!!!!!!
Very nice
thanks its helps me alote
you guys rock, thnx a lot for the program!!
thanks for this program.it did really helped me.thank u so much for posting this program.it is very much understanding
thanks for the code and if u want to be surprised by present day world please visit this and leave ur comments http://think-gadget.blogspot.in/
First of all i would like to say that any Matrix can have its transpose. So it is your first mistake where you mentioned that only square matrix' transpose is possible.
After that again at the end you just interchanged i and j,which is not correct coding.It suits only if it is a square matrix by chance because there is no of rows=no of columns always.
Post a Comment