forked from Pavan-Kamthane/Cpp_Lang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.cpp
49 lines (49 loc) · 1.21 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
#include<iostream>
using namespace std;
int main()
{
float numOne, numTwo, 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(1-5): ";
cin>>choice;
if(choice>=1 && choice<=4)
{
cout<<"\nEnter any two Numbers: ";
cin>>numOne>>numTwo;
}
switch(choice)
{
case 1:
res = numOne+numTwo;
cout<<"\nResult = "<<res;
break;
case 2:
res = numOne-numTwo;
cout<<"\nResult = "<<res;
break;
case 3:
res = numOne*numTwo;
cout<<"\nResult = "<<res;
break;
case 4:
res = numOne/numTwo;
cout<<"\nResult = "<<res;
break;
case 5:
return 0;
default:
cout<<"\nWrong Choice!";
break;
}
cout<<"\n------------------------\n";
}while(choice!=5);
cout<<endl;
return 0;
}