-
Notifications
You must be signed in to change notification settings - Fork 0
/
Matrix_Add.cpp
54 lines (38 loc) · 1023 Bytes
/
Matrix_Add.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
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
int a[3][3],b[3][3],c[3][3],i,j;
cout<<"Enter the 1st Matrix\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>a[i][j];
}
}
cout<<"Enter the 2nd Matrix\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>b[i][j];
}
}
cout<<"The sum of 1st and 2nd Matrix is:\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j] = a[i][j] + b[i][j];
cout<<c[i][j]<<" ";
}
cout<<"\n";
}
return 0;
}