forked from m1n199honey/cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculater.cpp
More file actions
29 lines (27 loc) · 724 Bytes
/
calculater.cpp
File metadata and controls
29 lines (27 loc) · 724 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
#include<iostream>
using namespace std;
void calculater(){
int n1,n2;
char ch;
again:
cout<<"Choose operater :-"<<endl
<<" '+' for Addition"<<endl
<<" '-' for subtraction"<<endl
<<" '*' for Multiplication"<<endl
<<" '/' for Division"<<endl;
cout<<"Example 2 + 3 <- dont forgot the space"<<endl;
cin>>n1;
cin>>ch;
cin>>n2;
switch(ch){
case '+':cout<<" = "<<n1+n2<<endl;break;
case '-':cout<<" = "<<n1-n2<<endl;break;
case '*':cout<<" = "<<n1*n2<<endl;break;
case '/':cout<<" = "<<(float)n1/n2<<endl;break;
default: cout<<"wrong ❌ choose again"; goto again;
}
}
int main(){
char ch;
calculater();
}