-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator.cpp
85 lines (85 loc) · 1.52 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
#include<iostream>
using namespace std;
int add(int a,int b)
{
return a+b;
}
int sub(int a,int b)
{
return a-b;
}
int mul(int a,int b)
{
return a*b;
}
int div(int a,int b)
{
return a/b;
}
int main()
{
int a,b,ch;
cout<<"\n\n\t\t\t\t\t\t My Simple Calculator \n";
cout<<"\n 1. Addition : ";
cout<<"\n 2. Subtraction : ";
cout<<"\n 3. Multiplication : ";
cout<<"\n 4. Division : ";
do
{
cout<<"\n\nSelect Opertation :: ";
cin>>ch;
switch(ch)
{
case 1:
cout<<"\n\nEnter First Number :: ";
cin>>a;
cout<<"\nEnter Second Number :: ";
cin>>b;
cout<<"\n";
cout<<a;
cout<<" + ";
cout<<b;
cout<<" = ";
cout<<add(a,b);
break;
case 2:
cout<<"\nEnter First Number :: ";
cin>>a;
cout<<"\nEnter Second Number :: ";
cin>>b;
cout<<"\n";
cout<<a;
cout<<" - ";
cout<<b;
cout<<" = ";
cout<<sub(a,b);
break;
case 3:
cout<<"\nEnter First Number :: ";
cin>>a;
cout<<"\nEnter Second Number :: ";
cin>>b;
cout<<"\n";
cout<<a;
cout<<" * ";
cout<<b;
cout<<" = ";
cout<<mul(a,b);
break;
case 4:
cout<<"\nEnter First Number :: ";
cin>>a;
cout<<"\nEnter Second Number :: ";
cin>>b;
cout<<"\n";
cout<<a;
cout<<" / ";
cout<<b;
cout<<" = ";
cout<<div(a,b);
break;
case 5: cout<<"\nInvalid Choice";
break;
}
}while(ch<6);
}