-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasic_Calculator.cpp
More file actions
67 lines (65 loc) · 1.84 KB
/
Basic_Calculator.cpp
File metadata and controls
67 lines (65 loc) · 1.84 KB
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
//will use goto statements for quitting from any operation
#include <iostream>
using namespace std;
int main()
{
int op,a,b;
cout<<"\t CALCULATOR"<<endl;
//using numbers to get the operation type by user
cout<<"press 1 for Addition"<<endl;
cout<<"press 2 for substraction"<<endl;
cout<<"press 3 for Multiplication"<<endl;
cout<<"press 4 for Division"<<endl;
cout<<"Press 5 to quit"<<endl;
start:
cout<<"enter your choice as per the above mentioned references for operations : ";
cin>>op;
if(op == 1){
cout<<"\tADDITION"<<endl;
cout<<" Enter the first number : ";
cin>>a;
cout<<" Enter the second number : ";
cin>>b;
cout<<"\tThe addition is :"<<a+b<<endl;
goto start;
}
else if(op == 2){
cout<<"\tSUBSTRACTION"<<endl;
cout<<" Enter the first number : ";
cin>>a;
cout<<" Enter the second number : ";
cin>>b;
cout<<"\tThe substraction is :"<<a-b<<endl;
goto start;
}
else if(op == 3){
cout<<"\tMULTIPLICATION"<<endl;
cout<<" Enter the first number : ";
cin>>a;
cout<<" Enter the second number : ";
cin>>b;
cout<<"\tThe multipliction is :"<<a*b<<endl;
goto start;
}
else if(op == 4){
cout<<"\tDIVISION"<<endl;
cout<<"enter the larger number first"<<endl;
cout<<" Enter the first number : ";
cin>>a;
cout<<" Enter the second number : ";
cin>>b;
cout<<"\tThe dividion is :"<<a/b<<endl;
goto start;
}
else if(op == 5){
cout<<"\t Quitting the program";
goto end;
}
else{
cout<<"\t\tNVALID_INPUT---ERROR"<<endl;
cout<<"please enter a valid number for choice of operation";
goto start;
}
end:
return 0;
}