Question:

write a program in c to find the sum of 2 matrices of order mxn

by Guest9920  |  12 years, 7 month(s) ago

0 LIKES UnLike

write a program in c to find the sum of 2 matrices of order mxn

 Tags: matrices, MXN, Program, Sum, write

   Report

3 ANSWERS

  1. amomipais82
    Hi,
    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.
      32. cout<<endl<<"Displaying Matrix A: "<<endl<<endl;
      33. for(i=0;i<m;i++)
      34. {
      35. for(j=0;j<n;j++)
      36. {
      37. cout<<a[i][j]<<" ";
      38. }
      39. cout<<endl<<endl;
      40. }
      41. cout<<endl<<"Displaying Matrix B: "<<endl<<endl;
      42. for(i=0;i<m;i++)
      43. {
      44. for(j=0;j<n;j++)
      45. {
      46. cout<<b[i][j]<<" ";
      47. }
      48. cout<<endl<<endl;
      49. }
      50. cout<<endl<<"Matrix A + Matrix B = Matrix C: "<<endl<<endl;
      51. for(i=0;i<m;i++)
      52. {
      53. for(j=0;j<n;j++)
      54. {
      55. cout<<a[i][j]+b[i][j]<<" ";
      56. }
      57. cout<<endl<<endl;
      58. }
      59.
      60. getch();
      61. }

    Hope it helps

  2. Guest9542
    [-2 7]+[ 3 -6]
    [ o 4] [-1 -5]
  3. Guest6280
    how fast can i get my answer
Sign In or Sign Up now to answser this question!

Question Stats

Latest activity: 14 years, 6 month(s) ago.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions