-
Notifications
You must be signed in to change notification settings - Fork 0
/
23_MatrixSum.cpp
57 lines (53 loc) · 1.11 KB
/
23_MatrixSum.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
57
#include <bits/stdc++.h>
using namespace std;
int main()
{
int arr1[3][3];
int arr2[3][3];
int arr3[3][3];
cout<<"enter elements for matrix 1:"<<endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cin >> arr1[i][j];
}
}
cout<<"matrix 1 is:"<<endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cout << arr1[i][j] << " ";
}
cout << endl;
}
cout<<"enter elements for matrix 2:"<<endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cin >> arr2[i][j];
}
}
cout<<"matrix 2 is:"<<endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cout << arr2[i][j] << " ";
}
cout << endl;
}
cout<<"after addition of both matrix is:"<<endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
arr3[i][j]=(arr1[i][j]+arr2[i][j]);
cout<<arr3[i][j]<<" ";
}
cout << endl;
}
return 0;
}