Advertisement
Waliul

Matric Addition(A+B+C)

Mar 9th, 2021
653
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int i, j, k, n, m, r, c;
  7.     cout<<"Enter the dimension of the matrices\n";
  8.     cout<<"Number of rows : ";
  9.     cin>>r;
  10.     cout<<"Number of columns : ";
  11.     cin>>c;
  12.     int A[r][c], B[r][c], C[r][c];
  13.     cout<<"Enter the elements of A matrice :\n";
  14.     for(i = 0; i < r; i++)
  15.         for(j = 0; j < c; j++)
  16.             cin>>A[i][j];
  17.     cout<<"Enter the elements of B matrice :\n";
  18.     for(i = 0; i < r; i++)
  19.         for(j = 0; j < c; j++)
  20.             cin>>B[i][j];
  21.     cout<<"Enter the elements of C matrice :\n";
  22.     for(i = 0; i < r; i++)
  23.         for(j = 0; j < c; j++)
  24.             cin>>C[i][j];
  25.     cout<<"A+B+C : \n";
  26.     for(i = 0; i < r; i++)
  27.     {
  28.         for(j = 0; j < c; j++)
  29.             cout<<A[i][j]+B[i][j]+C[i][j]<<" ";
  30.         cout<<endl;
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement