forked from Ankur-Kumar-Gupta/Programming_Practice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.cpp
46 lines (45 loc) · 1.48 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
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
char cal;
cout<<"Hey there, which operation you want to perform: "<<endl;
cout<<"a:Add"<<endl<<"b:Subtract"<<endl<<"c:Multiply"<<endl<<"d:Divide"<<endl;
cout<<"Press the number key of operation: ";
cin>>cal;
switch (cal)
{
case 'a': cout<<"Enter first number:";
cin>>a;
cout<<"Enter second number:";
cin>>b;
c=a+b;
cout<<"The sum is ="<<c<<endl;
break;
case 'b': cout<<"Enter first number:";
cin>>a;
cout<<"Enter second number:";
cin>>b;
c=a-b;
cout<<"The result is ="<<c<<endl;
break;
case 'c': cout<<"Enter first number:";
cin>>a;
cout<<"Enter second number:";
cin>>b;
c=a*b;
cout<<"The result is ="<<c<<endl;
break;
case 'd': cout<<"Enter first number:";
cin>>a;
cout<<"Enter second number:";
cin>>b;
c=a/b;
cout<<"The result is ="<<c<<endl;
break;
default: cout<<"You have entered a wrong choice.Pls Enter a right choice.";
break;
}
return 0;
}