-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreal_calc.cpp
80 lines (73 loc) · 1.46 KB
/
real_calc.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>
using namespace std;
int add()
{
int a,b;
cout<<"Enter first number :";
cin>>a;
cout<<"Enter second number :";
cin>>b;
cout<<"The sum is :"<<a+b;
}
int sub()
{
int a,b;
cout<<"Enter first number :";
cin>>a;
cout<<"Enter second number :";
cin>>b;
cout<<"The subtraction is :"<<a-b;
}
int mul()
{
int a,b;
cout<<"Enter first number :";
cin>>a;
cout<<"Enter second number :";
cin>>b;
cout<<"The multiplication is :"<<a*b;
}
int div()
{
int a,b;
cout<<"Enter first number :";
cin>>a;
cout<<"Enter second number :";
cin>>b;
cout<<"The subtraction is :"<<a/b;
}
int mod()
{
int a,b;
cout<<"Enter first number :";
cin>>a;
cout<<"Enter second number :";
cin>>b;
cout<<"The subtraction is :"<<a%b;
}
int main()
{
char b=240,ch,x;
cout<<b<<b<<b<<"-- Calculator by Yash Lade --"<<b<<b<<b<<endl;
do
{
cout<<"\n\nPress + for performing addition ";
cout<<"\nPress - for performing substraction ";
cout<<"\nPress * for performing multiplication ";
cout<<"\nPress / for performing division ";
cout<<"\nPress % for performing modulus ";
cout<<"\nPress x to exit the program \n";
cout<<"Enter your choice :";
cin>>ch;
switch(ch)
{
case '+':add();break;
case '-':sub();break;
case '*':mul();break;
case '/':div();break;
case '%':mod();break;
case 'x':break;
default :cout<<"Wrong choice !!\n";
}
}while(ch!=x);
}