-
Notifications
You must be signed in to change notification settings - Fork 3
/
calculator.cpp
95 lines (94 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
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
89
90
91
92
93
94
#include <iostream>
using namespace std;
float subtract(float a,float b)
{
float sub=a-b;
return sub;
}
float multiply(float a,float b)
{
float mul=a*b;
return mul;
}
int divide(int a,int b)
{
int div= a/b;
return div;
}
int max(int a,int b)
{
if(a>b)
{
return a;
}
else
{
return b;
}
}
int min(int a,int b)
{
if(a<b)
{
return a;
}
else
{
return b;
}
}
int square(int a)
{
int result=a*a;
return result;
}
int cube(int a)
{
int result=a*a*a;
return result;
}
int main()
{
cout<<"_CHOOSE OPTION_"<<endl;
cout<<"1.subraction"<<endl;
cout<<"2.multipication"<<endl;
cout<<"3.division"<<endl;
cout<<"4.maximum of 2 numbers"<<endl;
cout<<"5.minimum of 2 numbers"<<endl;
cout<<"6.square"<<endl;
cout<<"7.cube"<<endl;
int a;
cin>>a;
cout<<"_ENTER NUMBERS TO OPERATE_"<<endl;
int x,y;
cin>>x>>y;
if(a==1)
{
cout<<"subraction= "<<subtract(x,y)<<endl;
}
if(a==2)
{
cout<<"multipication= "<<multiply(x,y)<<endl;
}
if(a==3)
{
cout<<"division= "<<divide(x,y)<<endl;
}
if(a==4)
{
cout<<"maximum of 2 numbers= "<<max(x,y)<<endl;
}
if(a==5)
{
cout<<"minimum of 2 numbers= "<<min(x,y)<<endl;
}
if(a==6)
{
cout<<"square= "<<square(x)<<endl;
}
if(a==7)
{
cout<<"cube= "<<cube(x)<<endl;
}
return 0;
}