Advertisement
EconomicSerg

Calculator in C++

Jan 26th, 2021
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3.  
  4. using namespace std;
  5.  
  6. int a;
  7. int b;
  8. string math;
  9.  
  10. int main() {
  11.  
  12.     cout << "Enter a number: " << endl;
  13.     cin >> a;
  14.     cout << "Enter another number: " << endl;
  15.     cin >> b;
  16.     cout << "Enter method of math (+ - * /)" << endl;
  17.     cin >> math;
  18.  
  19.     if (math == "+") {
  20.         cout << a + b << endl;
  21.     } else if (math == "-") {
  22.         cout << a - b << endl;
  23.     } else if (math == "*") {
  24.         cout << a * b << endl;
  25.     } else if (math == "/") {
  26.         cout << a / b << endl;
  27.     } else {
  28.         cout << "That is not a valid method of math!" << endl;
  29.     }
  30.     return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement