W.A.P. C++

WAP | CPP | Programs in C++ | C++ Solutions

Write a program to find transpose of a matrix


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 :)
  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. int a[10][10],m,n,i,j;
  7. cout<<"Enter number of rows: ";
  8. cin>>m;
  9. cout<<"Enter number of coloumns: ";
  10. cin>>n;
  11. //Coding by: Snehil Khanor
  12. //http://WapCPP.blogspot.com
  13. if(m!=n)
  14. {
  15. cout<<"Matrix not square so Transpose not possible :(";
  16. }
  17. else
  18. {
  19. cout<<endl<<"Enter elements of matrix: "<<endl;
  20. for(i=0;i<m;i++)
  21. {
  22. for(j=0;j<n;j++)
  23. {
  24. cout<<"Enter element a"<<i+1<<j+1<<": ";
  25. cin>>a[i][j];
  26. }
  27. }
  28. cout<<endl<<"Displaying Matrix: "<<endl<<endl;
  29. for(i=0;i<m;i++)
  30. {
  31. for(j=0;j<n;j++)
  32. {
  33. cout<<a[i][j]<<" ";
  34. }
  35. cout<<endl<<endl;
  36. }
  37. cout<<endl<<"Displaying Matrix Transpose: "<<endl<<endl;
  38. for(i=0;i<m;i++)
  39. {
  40. for(j=0;j<n;j++)
  41. {
  42. cout<<a[j][i]<<" ";
  43. }
  44. cout<<endl<<endl;
  45. }
  46. }
  47. getch();
  48. }

13 comments:

rabia May 12, 2011 at 7:00 AM  

thanks for this code understanding

Cpp Programs June 7, 2011 at 11:48 PM  

by doing lot of efforts i have have founded a blog related to my blog topic................visit my blog http://cpp-programs.blogspot.com/

Anonymous June 20, 2011 at 2:21 PM  

thanks

Anonymous July 28, 2011 at 11:12 PM  

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

Anonymous August 5, 2011 at 7:08 PM  

thanks for this code understanding

Anonymous August 13, 2011 at 11:03 AM  

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 ).

Anonymous October 2, 2011 at 12:07 PM  

transpose is also possible even if rows and columns are not equal, i.e, mXn matrix becomes nXm

Anonymous October 10, 2011 at 12:23 AM  

i just dnt understand CP
why is it compulsory in FE
scrap................!!!!!!!!!!!!!!

Ami Baig December 25, 2011 at 2:48 PM  

Very nice
thanks its helps me alote

Anonymous January 15, 2012 at 10:36 PM  

you guys rock, thnx a lot for the program!!

Suhana Mukthar February 17, 2012 at 11:59 AM  

thanks for this program.it did really helped me.thank u so much for posting this program.it is very much understanding

somu March 2, 2012 at 5:40 AM  

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/

Anonymous September 18, 2012 at 2:18 PM  

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.

Search

About WAP C++

Here you'll find a wide range of programs' solution ranging from beginer level to advanced level.
All programs here are made, compiled and tested by me..and are running absolutely fine.. still if you find any bug in any program do let me know :)

Followers

Subscribe via email

Enter your email address:

Delivered by FeedBurner

my Binary Log

Recent Posts

Blog Archive



eXTReMe Tracker