Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<conio.h>
- using namespace std;
- int main(){
- char op;
- float a,b;
- cout << "Select a operator from + or +- or * or / : ";
- cin >> op;
- cout << "Enter two operands: ";
- cin >> a >> b;
- switch(op){
- case '+':
- cout << a+b;
- break;
- case '-':
- cout << a-b;
- break;
- case '*':
- cout << a*b;
- break;
- case '/':
- cout << a/b;
- break;
- default:
- cout << "Error! operator is not correct.";
- cout<< "\n Please enter a right operator and try again.";
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement