-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.cpp
88 lines (64 loc) · 2.11 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include<iostream>
using namespace std;
int main()
{
int a,b,ch,add,mul,sub,mod,comp;
float div;
cout<<"\n @Author Name - Yash Lade !!\n;
cout<<"Calculator \n";
do
{
cout<<"\n\nPress 1 for addition \n";
cout<<"Press 2 for Substraction \n";
cout<<"Press 3 for Multiplication \n";
cout<<"Press 4 for Division \n";
cout<<"Press 5 for Modulus \n";
cout<<"Press 6 for Comparsion between two numbers\n";
cout<<"Press 7 to exit !!\n";
cout<<"\nEnter Your Choice :";
cin>>ch;
switch(ch)
{
case 1:cout<<"Enter the first number :";
cin>>a;
cout<<"Enter the second number :";
cin>>b;
add=a+b;
cout<<"\nThe addition of "<<a<<" and "<<b<<" is "<<add;break;
case 2:cout<<"Enter the first number :";
cin>>a;
cout<<"Enter the second number :";
cin>>b;
sub=a-b;
cout<<"\nThe substraction(a-b) of "<<a<<" and "<<b<<" is "<<sub<<endl;break;
case 3:cout<<"Enter the first number :";
cin>>a;
cout<<"Enter the second number :";
cin>>b;
mul=a*b;
cout<<"\nThe multiplication of "<<a<<" and "<<b<<" is "<<mul<<endl;break;
case 4:cout<<"Enter the first number :";
cin>>a;
cout<<"Enter the second number :";
cin>>b;
div=a/b;
cout<<"\nThe division(a/b) of "<<a<<" and "<<b<<" is "<<div<<endl;break;
case 5:cout<<"Enter the first number :";
cin>>a;
cout<<"Enter the second number :";
cin>>b;
mod=a%b;
cout<<"\nThe modulus of "<<a<<" and "<<b<<" is "<<mod<<endl;break;
case 6:cout<<"Enter the first number :";
cin>>a;
cout<<"Enter the second number :";
cin>>b;
if(a<b)
cout<<"\nB is greater than A that is "<<b<<" is greater than "<<a;
else
cout<<"\nA is greater than B that is "<<a<<" is greater than "<<b;
break;
case 7:break;
}
}while (ch!=7);
}