W.A.P. C++

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

Snehil Khanor's Binary Log

Write a program for multiplication of two matrices


Two matrices are taken from user..multiplication matrix 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],b[10][10],c[10][10],m,n,o,p,i,j;
  7. cout<<"Enter number of rows of A: ";
  8. cin>>m;
  9. cout<<"Enter number of coloumns of A: ";
  10. cin>>n;
  11. cout<<endl<<"Enter elements of matrix A: "<<endl;
  12. //Coding by: Snehil Khanor
  13. //http://WapCPP.blogspot.com
  14. for(i=0;i<m;i++)
  15. {
  16. for(j=0;j<n;j++)
  17. {
  18. cout<<"Enter element a"<<i+1<<j+1<<": ";
  19. cin>>a[i][j];
  20. }
  21. }
  22. cout<<endl<<"Enter number of rows of B: ";
  23. cin>>o;
  24. cout<<"Enter number of coloumns of B: ";
  25. cin>>p;
  26. cout<<endl<<"Enter elements of matrix B: "<<endl;
  27. for(i=0;i<o;i++)
  28. {
  29. for(j=0;j<p;j++)
  30. {
  31. cout<<"Enter element b"<<i+1<<j+1<<": ";
  32. cin>>b[i][j];
  33. }
  34. }
  35. cout<<endl<<"Displaying Matrix A: "<<endl<<endl;
  36. for(i=0;i<m;i++)
  37. {
  38. for(j=0;j<n;j++)
  39. {
  40. cout<<a[i][j]<<" ";
  41. }
  42. cout<<endl<<endl;
  43. }
  44. cout<<endl<<"Displaying Matrix B: "<<endl<<endl;
  45. for(i=0;i<o;i++)
  46. {
  47. for(j=0;j<p;j++)
  48. {
  49. cout<<b[i][j]<<" ";
  50. }
  51. cout<<endl<<endl;
  52. }
  53. if(n==o)
  54. {
  55. for(i=0;i<m;i++)
  56. {
  57. for(j=0;j<p;j++)
  58. {
  59. c[i][j]=0;
  60. for(int k=0;k<n;k++)
  61. {
  62. c[i][j]=c[i][j]+a[i][k]*b[k][j];
  63. }
  64. }
  65. }
  66. cout<<endl<<"Matrix A * Matrix B = Matrix C: "<<endl<<endl;
  67. for(i=0;i<m;i++)
  68. {
  69. for(j=0;j<p;j++)
  70. {
  71. cout<<c[i][j]<<" ";
  72. }
  73. cout<<endl<<endl;
  74. }
  75. }
  76. else
  77. cout<<"Multiplication not possible :(";
  78. getch();
  79. }

10 comments:

Anonymous September 20, 2011 at 1:00 AM  

good work keep it up .... tomarrow is my test it will help me for saving my grade

Anonymous September 20, 2011 at 1:02 AM  

good work keep it up .... tomarrow is my test it will help me for saving my grade.....azeem mumtaz(electrical engineer)

Anonymous October 10, 2011 at 7:09 PM  

thanks a lot. i am gonna write this in my model exam.

amr November 9, 2011 at 5:50 PM  

thanks
by
www.cybertechmasters.blogspot.com
link me friend..

Jayanth March 30, 2012 at 12:43 AM  

Thank you very much its help to write my assignment

Anonymous April 4, 2012 at 12:38 AM  

dis is wrong...:P

Unknown July 18, 2012 at 1:47 PM  

programm done by mohit...

Anonymous November 6, 2012 at 12:50 AM  

Oye kutte ,sasur ka nati e ka hai!koi addres wa hai ka!

Anonymous February 14, 2014 at 8:46 AM  

Hey guys please visit visitpayment.com/?ref=73813 to make any money, just take a peek at least thank u..

Anonymous May 13, 2014 at 1:00 AM  

saala kya ghatiya program hai bas input dete jaao output aata hi nhi hai #chu_iya saale

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

Blog Archive



eXTReMe Tracker