W.A.P. C++

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

Snehil Khanor's Binary Log

Write a program to find sum matrix of two matrix


Two matrix are taken from user.. Sum 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,i,j;
  7. cout<<"Enter number of rows: ";
  8. cin>>m;
  9. cout<<"Enter number of coloumns: ";
  10. cin>>n;
  11. cout<<endl<<"Enter elements of matrix A: "<<endl;
  12. for(i=0;i<m;i++)
  13. {
  14. for(j=0;j<n;j++)
  15. {
  16. cout<<"Enter element a"<<i+1<<j+1<<": ";
  17. cin>>a[i][j];
  18. }
  19. }
  20. cout<<endl<<"Enter elements of matrix B: "<<endl;
  21. //Coding by: Snehil Khanor
  22. //http://WapCPP.blogspot.com
  23. for(i=0;i<m;i++)
  24. {
  25. for(j=0;j<n;j++)
  26. {
  27. cout<<"Enter element b"<<i+1<<j+1<<": ";
  28. cin>>b[i][j];
  29. }
  30. }
  31. cout<<endl<<"Displaying Matrix A: "<<endl<<endl;
  32. for(i=0;i<m;i++)
  33. {
  34. for(j=0;j<n;j++)
  35. {
  36. cout<<a[i][j]<<" ";
  37. }
  38. cout<<endl<<endl;
  39. }
  40. cout<<endl<<"Displaying Matrix B: "<<endl<<endl;
  41. for(i=0;i<m;i++)
  42. {
  43. for(j=0;j<n;j++)
  44. {
  45. cout<<b[i][j]<<" ";
  46. }
  47. cout<<endl<<endl;
  48. }
  49. cout<<endl<<"Matrix A + Matrix B = Matrix C: "<<endl<<endl;
  50. for(i=0;i<m;i++)
  51. {
  52. for(j=0;j<n;j++)
  53. {
  54. cout<<a[i][j]+b[i][j]<<" ";
  55. }
  56. cout<<endl<<endl;
  57. }
  58. getch();
  59. }

1 comments:

Swetha February 25, 2013 at 7:05 PM  

U assigned a 2-D array c[10][10] in the beginning which is never used in the program.. why?

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