-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6-Calculator.cpp
More file actions
47 lines (38 loc) · 867 Bytes
/
6-Calculator.cpp
File metadata and controls
47 lines (38 loc) · 867 Bytes
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
#include <iostream>
using namespace std;
int main(){
char operation;
float num1, num2;
cout << "Enter first number - ";
cin >> num1;
cout << "Enter second number - ";
cin >> num2;
cout<<"Select the Operation ( +, -, *, / )"<<endl;
cout << "Enter Operation: ";
cin >> operation;
switch (operation)
{
case '+':
cout << "The Result is - " << num1 + num2;
break;
case '-':
cout << "The Result is - " << num1 - num2;
break;
case '*':
cout << "The Result is - " << num1 * num2;
break;
case '/':
if (num2!=0)
{
cout << "The Result is - " << num1/num2;
}
else{
cout << "This operation is not possible" <<endl;
}
break;
default:
cout << "Invalid Operation";
break;
}
return 0;
}