-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.cpp
57 lines (38 loc) · 913 Bytes
/
game.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<iostream>
using namespace std;
int main(){
//Using const int for array size
const int row=2,col=2;
// if not use const error found
cout<<"Size of Matrices : "<<row<<" X "<<col<<endl;
cout<<"Enter Value For First Matrix:"<<endl;
int first[row][col], second[row][col];
int x,j;
for( x=0;x<row;x++){
cout<<"Enter value for row number: "<<x+1<<endl;
for( j=0;j<col;j++){
cin>>first[x][j];
}
}
cout<<"\n\n\nEnter Value For Second Matrix:"<<endl;
for( x=0;x<row;x++){
cout<<"Enter value for row number: "<<x+1<<endl;
for( j=0;j<col;j++){
cin>>second[x][j];
}
}
// Resultant Matrix
for( x=0;x<row;x++){
for( j=0;j<col;j++){
first[x][j]=first[x][j]+second[x][j];
}
}
cout<<"\n\n\t\tResultant Matrix:"<<endl;
for( x=0;x<row;x++){
cout<< endl;
for( j=0;j<col;j++){
cout<<"\t\t"<<first[x][j]<<" ";
}
}
return 0;
}