-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcalculator.cpp
More file actions
35 lines (34 loc) · 823 Bytes
/
Copy pathcalculator.cpp
File metadata and controls
35 lines (34 loc) · 823 Bytes
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
#include<iostream>
using namespace std;
int main() {
int choice,a,b;
cout<<"CALCULATOR"<<endl;
cout<<"1. Addition"<<endl;
cout<<"2. Subtraction"<<endl;
cout<<"3. Multiplication"<<endl;
cout<<"4. Division"<<endl;
cout<<"Enter your choice : "<<endl;
cin>>choice;
cout<<"Enter 2 numbers : "<<endl;
cin>>a>>b;
switch(choice) {
case 1:
cout<<"Addition : "<<a+b<<endl;
break;
case 2:
cout<<"Subtraction : "<<a-b<<endl;
break;
case 3:
cout<<"Multiplication : "<<a*b<<endl;
break;
case 4:
if(b!=0)
cout<<"Division : "<<a/b<<endl;
else
cout<<"Division by zero is not allowed."<<endl;
break;
default:
cout<<"Invalid choice."<<endl;
}
return 0;
}