forked from DHEERAJHARODE/Hacktoberfest2024-Open-source-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.cpp
59 lines (41 loc) · 1.22 KB
/
calculator.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>
#include <iomanip>
#include <cstdlib>
using namespace std;
int main(){
cout << "Enter first number : " << flush;
int num1;
cin >> num1;
cout << "Enter second number : " << flush;
int num2;
cin >> num2;
cout << "CALCULATOR" << endl;
cout << "1.Add" << endl;
cout << "2.Subtract" << endl;
cout << "3.Divide" << endl;
cout << "4.Multiply" << endl;
cout << "Which operation do you want to perform (select a number from above given options) : " << flush;
int option;
cin >> option;
switch(option){
case 1:
cout << "Adding given numbers..." << endl;
cout <<"Result = " << num1+num2 << endl;
break;
case 2:
cout << "Subtracting given numbers..." <<endl;
cout <<"Result = " << num1 - num2<<endl;
break;
case 3:
cout << "Dividing given numbers..." <<endl;
cout <<"Result = " << (float)num1/num2 <<endl;
break;
case 4:
cout << "Multiplying given numbers..." <<endl;
cout <<"Result = " << num1*num2 <<endl;
break;
default:
cout << "INVALID INPUT" << endl;
}
return 0;
}