-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calculator.cpp
50 lines (50 loc) · 1.23 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
#include<iostream>
using namespace std;
int main()
{
float num1, num2, res;
int choice;
do
{
cout<<"1. Addition\n";
cout<<"2. Subtraction\n";
cout<<"3. Multiplication\n";
cout<<"4. Division\n";
cout<<"5. Exit\n\n";
cout<<"Enter Your Choice: ";
cin>>choice;
if(choice>=1 && choice<=4)
{
cout<<"\nEnter any two Numbers: ";
cin>>num1>>num2;
}
switch(choice)
{
case 1:
res = num1+num2;
cout<<"\nResult = "<<res;
break;
case 2:
res = num1-num2;
cout<<"\nResult = "<<res;
break;
case 3:
res = num1*num2;
cout<<"\nResult = "<<res;
break;
case 4:
res = num1/num2;
cout<<"\nResult = "<<res;
break;
case 5:
return 0;
default:
cout<<"\nWrong Choice!";
break;
}
cout<<"\n------------------------\n";
}
while(choice!=5);
cout<<endl;
return 0;
}