-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrixAdder.cpp
More file actions
55 lines (49 loc) · 1.24 KB
/
MatrixAdder.cpp
File metadata and controls
55 lines (49 loc) · 1.24 KB
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
#include <iostream>
using namespace std;
int main(){
int y,z;
cout<<"Enter the rows and columns for the 2d arrays: ";
cin>>y>>z;
int arrA[y][z],arrB[y][z],arrC[y][z];
cout<<"Fill up the first array:"<<endl;
for(int i=0;i<y;i++){
for(int j=0;j<z;j++){
cin>>arrA[i][j];
}
}
cout<<"The first array is:"<<endl;
for(int i=0;i<y;i++){
for(int j=0;j<z;j++){
cout<<arrA[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
cout<<"Fill up the second array: "<<endl;
for(int i=0;i<y;i++){
for(int j=0;j<z;j++){
cin>>arrB[i][j];
}
}
cout<<"The second array is:"<<endl;//THIS RIGHT HERE IS THE FUNCTION THAT YOU NEED TO REMEMBER...
for(int i=0;i<y;i++){
for(int j=0;j<z;j++){
cout<<arrB[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
for(int i=0;i<y;i++){
for(int j=0;j<z;j++){
arrC[i][j]=arrA[i][j]+arrB[i][j];
}
}
cout<<"The sum of the second and the first array is:"<<endl;
for(int i=0;i<y;i++){
for(int j=0;j<z;j++){
cout<<arrC[i][j]<<" ";
}
cout<<endl;
}
return 0;
}