Advertisement
ItzStaze

Calculator

Sep 23rd, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int a;
  9.     int b;
  10.     int c;
  11.     cout << "1 for addition\n2 for subtraction\n3 for Multiplication\n4 for Division\n";
  12.     cin >> a;
  13.     cout << "Enter first number." << "\n>";
  14.     cin >> b;
  15.     cout << "Enter second number\n>";
  16.     cin >> c;
  17.    
  18.     if(a == 1)
  19.     {
  20.         cout << b+c;
  21.     }
  22.     else if(a == 2)
  23.     {
  24.         cout << b-c;
  25.     }
  26.     else if(a == 3)
  27.     {
  28.         cout << b*c;
  29.     }
  30.     else if(a == 4)
  31.     {
  32.         cout << b/c;
  33.     }
  34.     else
  35.     {
  36.         cout << "1 for Addition\n2 for Subtraction\n3 for Multiplication\n4 for Division\n";
  37.     }
  38.    
  39.     system("PAUSE");
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement