add two matrix

Solutions on MaxInterview for add two matrix by the best coders in the world

showing results for - "add two matrix"
Hannah
14 Jun 2020
1#include<iostream>
2using namespace std;
3
4int main() {
5    int Matrix_A[3][3] = { { 2,3,4 },
6                           { 5, 3, 4 },
7                            { 4, 8, 9 }   };
8
9    int Matrix_B[3][3] = { {3,4,5},
10                         {7,8,9},
11                          {2,3,4} };
12    int Matrix_C[3][3];
13    // for addition
14 
15
16            for (int i = 0; i < 3; i++) {
17                for (int j = 0; j < 3; j++) {
18                Matrix_C[i][j] =  Matrix_A[i][j] + Matrix_B[i][j];
19                }
20        }
21           
22            cout << " THis is the Adding of two Matrix " << endl;
23
24            for (int i = 0; i < 3; i++) {
25                for (int j = 0; j < 3; j++) {
26                    cout << Matrix_A[i][j] << " + " << Matrix_B[i][j] << " = " << Matrix_C[i][j] << endl;
27                }
28            }
29
30// 
31
32
33}