-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathAddition of two matrices ussing array.cpp
More file actions
59 lines (45 loc) · 1.15 KB
/
Addition of two matrices ussing array.cpp
File metadata and controls
59 lines (45 loc) · 1.15 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
56
57
58
59
/* C++ Program to Add Two Matrices using array */
#include<iostream>
using namespace std;
int main()
{
int arr1[5][5], arr2[5][5], arr3[5][5], sub, i, j,m,n;
cout<<"Enter size of matrix ( Max:5 ) :: ";
cin>>m;
cout<<"\nEnter Elements to Matrix A Below :: \n";
for(i=0;i<m;i++)
{
for(j=0;j<m;++j)
{
cout<<"\nEnter arr1["<<i<<"]["<<j<<"] Element :: ";
cin>>arr1[i][j];
}
}
cout<<"\nEnter Elements to Matrix B Below :: \n";
for(i=0;i<m;i++)
{
for(j=0;j<m;++j)
{
cout<<"\nEnter arr2["<<i<<"]["<<j<<"] Element :: ";
cin>>arr2[i][j];
}
}
cout<<"\nAdding Matrix ( A + B ) ..... \n";
for(i=0; i<m; i++)
{
for(j=0; j<m; j++)
{
arr3[i][j]=arr1[i][j]+arr2[i][j];
}
}
cout<<"\nAfter Addition, Matrix C is :: \n";
for (i = 0; i < m; ++i)
{
for (j = 0; j < m; ++j)
{
cout<<"\t"<<arr3[i][j];
}
printf("\n\n");
}
return 0;
}