-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculatorProFunction.cpp
80 lines (76 loc) · 1.44 KB
/
CalculatorProFunction.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
#include<iostream>
#include<cmath>
using namespace std;
void add(float a,float b)
{
cout<<"Sum = "<<a+b<<endl;
}
void sub(float a,float b)
{
cout<<"Subtract = "<<a-b<<endl;
}
void mul(float a,float b)
{
cout<<"Multiply = "<<a*b<<endl;
}
void div(float a,float b)
{
cout<<"Divide = "<<a/b<<endl;
}
void rem(int a,int b)
{
cout<<"Remainder = "<<a%b<<endl;
}
void powe(float a,float b)
{
cout<<"Power = "<<pow(a,b)<<endl;
}
int main()
{
float n1,n2;
int ch;
do
{
cout<<"Enter two numbers : "<<endl;
cin>>n1>>n2;
cout<<"\n*****************"<<endl;
cout<<"<1> Addition"<<endl;
cout<<"<2> Subtraction"<<endl;
cout<<"<3> Multiplication"<<endl;
cout<<"<4> Division"<<endl;
cout<<"<5> Remainder"<<endl;
cout<<"<6> Power"<<endl;
cout<<"<7> Exit"<<endl;
cout<<"Enter your choice : "<<endl;
cin>>ch;
switch (ch) {
case 1:
add(n1,n2);
break;
case 2:
sub(n1,n2);
break;
case 3:
mul(n1,n2);
break;
case 4:
div(n1,n2);
break;
case 5:
rem(n1,n2);
break;
case 6:
powe(n1,n2);
break;
case 7:
cout<<"Thank you."<<endl;
exit(0);
default:
cout<<"Invalid input."<<endl;
cout<<"Please enter a correct input."<<endl;
}
cout<<"\n**********************************\n"<<endl;
}
while(1);
return 0;
}