Guest User

Untitled

a guest
Nov 8th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     float a, b;
  6.     char operation;
  7.  
  8.     cout << "Enter 1st number: ";
  9.     cin >> a;
  10.     cout << "Enter 2nd number: ";
  11.     cin >> b;
  12.     cout << "Enter operation: ";
  13.     cin >> operation;
  14.  
  15.     switch (operation) {
  16.         case '+' :
  17.             cout << a << "+" << b << "=" << a + b;
  18.             break;
  19.         case '-' :
  20.             cout << a << "-" << b << "=" << a - b;
  21.             break;
  22.         case '*' :
  23.             cout << a << "*" << b << "=" << a * b;
  24.             break;
  25.         case '/' :
  26.             cout << a << "/" << b << "=" << a / b;
  27.             break;
  28.         default:
  29.             cout << "Error! There is no such operation!";
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment