-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatrix_Addition.cpp
58 lines (46 loc) · 1001 Bytes
/
Matrix_Addition.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
58
#include<bits/stdc++.h>
using namespace std;
void MatrixAdd(int A[][10],int B[][10],int n, int m){
int R[n][m];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
R[i][j] = A[i][j] + B[i][j];
}
}
cout<<"Result"<<endl;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cout<<R[i][j]<<" ";
}
cout<<endl;
}
}
int main(){
int n,m;
cout<<"Enter order of row: ";
cin>>n;
cout<<"Enter order of column: ";
cin>>m;
int A[n][10],B[n][10];
cout<<"Enter element for A matrix"<<endl;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cin>>A[i][j];
}
}
cout<<"Enter element for B matrix"<<endl;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cin>>B[i][j];
}
}
MatrixAdd(A,B,n,m);
}