-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path5_additionTwoMatrix.cpp
56 lines (51 loc) · 941 Bytes
/
5_additionTwoMatrix.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
@program: 5
Write a C++ Program for addition of Two Matrix.
*/
#include <iostream>
using namespace std;
int main()
{
int i, j, matrix1[3][3], matrix2[3][3];
cout << "Enter the 3X3 matrix1: ";
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
cin >> matrix1[i][j];
}
}
cout << "Enter the 3X3 matrix2: ";
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
cin >> matrix2[i][j];
}
}
cout << "\nAddition of two matrix..\n";
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
cout << matrix1[i][j] + matrix2[i][j] << " ";
}
cout << endl;
}
return 0;
}
/*
Output:
Enter the 3X3 matrix1:
2 2 2
3 3 3
4 4 4
Enter the 3X3 matrix2:
3 3 3
2 2 2
1 1 1
Addition of two matrix..
5 5 5
5 5 5
5 5 5
*/