-
Notifications
You must be signed in to change notification settings - Fork 5
/
substraction_of_array.cpp
57 lines (44 loc) · 1.11 KB
/
substraction_of_array.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()
{
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<<"\nSubtracting 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 Subtraction, 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;
}