Advertisement
mouhsineelachbi

Soj_Johnson

Nov 6th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include<conio.h>
  3.  
  4. using namespace std;
  5. int main(){
  6.  
  7.     char op;
  8.     float a,b;
  9.  
  10.     cout << "Select a operator from + or +- or * or / : ";
  11.     cin >> op;
  12.  
  13.     cout << "Enter two operands: ";
  14.     cin >> a >> b;
  15.  
  16.     switch(op){
  17.  
  18.         case '+':
  19.             cout << a+b;
  20.             break;
  21.  
  22.         case '-':
  23.             cout << a-b;
  24.             break;
  25.  
  26.         case '*':
  27.             cout << a*b;
  28.             break;
  29.  
  30.         case '/':
  31.             cout << a/b;
  32.             break;
  33.  
  34.         default:
  35.             cout << "Error! operator is not correct.";
  36.             cout<< "\n Please enter a right operator and try again.";
  37.             break;
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement