-
Notifications
You must be signed in to change notification settings - Fork 0
/
simplecalculator.cpp
61 lines (43 loc) · 990 Bytes
/
simplecalculator.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
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
int num1, num2, choice;
cout<<"SIMPLE CACULATOR"<<endl;
cout<<"enter first number: ";
cin>>num1;
cout<<"\nenter second number: ";
cin>>num2;
do{
cout<<"choose an operation from the following menu"<<endl;
cout<<"1.add\n2.subtract\n3.multiply\n4.divide\n5.exit\n";
cout<<"enter your choice: ";
cin>>choice;
switch(choice){
int sum, sub, mul;
float divide;
case 1:
sum=num1+num2;
cout<<num1<<"+"<<num2<<"="<<sum<<endl;
break;
case 2:
sub=num1-num2;
cout<<num1<<"-"<<num2<<"="<<sub<<endl;
break;
case 3:
mul=num1*num2;
cout<<num1<<"*"<<num2<<"="<<mul<<endl;
break;
case 4:
divide=num1/num2;
cout<<num1<<"/"<<num2<<"="<<divide<<endl;
break;
case 5:
exit(0);
break;
default:
cout<<"\nwrong choice\n";
}
}while(choice!=6);
return 0;
}