-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubtract-matrices-180.cpp
52 lines (47 loc) · 1.5 KB
/
subtract-matrices-180.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
/*
Task-> Subsract Two Matrices by taking input from the user.
1.Start.
2.Take rowInput && columnsInput.
3.Take firstMatrix as input from the user.
4.Take secondMatrix as input from the user.
5.Subsract from firstMatrix to secondMatrix.
6.Show the result.
7.Stop.
*/
#include <iostream>
using namespace std;
int inputRows,inputColumns,i,j;
int firstMatrix[10][10],secondMatrix[10][10],result[10][10];
int subtract(){
cout <<"Enter the number of Rows && Columns :"<< endl;
cin >>inputRows >>inputColumns;
cout << "Enter the elements of first Matrix :"<< endl;
for(i=0; i<inputRows; i++) {
for(j=0; j<inputColumns; j++) {
cin >> firstMatrix[i][j];
}
}
cout <<"Enter the elements of second Matrix : "<<endl;
for(i=0; i<inputRows; i++) {
for(j=0; j<inputColumns; j++) {
cin >> secondMatrix[i][j];
}
}
//Substraction Part..
for(i=0; i<inputRows; i++) {
for(j=0; j<inputColumns; j++) {
result[i][j] = secondMatrix[i][j]-firstMatrix[i][j];
}
}
//Difference of entered Matrices :
cout << "Difference of entered Matrices: "<< endl;
for(i=0; i<inputRows; i++) {
for(j=0; j<inputColumns; j++) {
cout<< "\t" << result[i][j];
}
}
}
int main()
{
subtract();
}