Advertisement
Guest User

Untitled

a guest
May 27th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main ()
  6. {
  7.     bool done = false;
  8.    
  9.     do  {        //loops program
  10.        
  11.         begin_cycle:;
  12.         int a, b;
  13.         string opr;
  14.  
  15.         cout << "First Number: ";
  16.         cin >> a;
  17.         cout << "Second Number: ";
  18.         cin >> b;
  19.         begin_cycle2:;
  20.         cout << "Operator?[a][s][m][d]: ";
  21.         cin >> opr;
  22.  
  23.         if ( opr == "a" )
  24.         {
  25.             int r;
  26.             r=a+b;
  27.             cout << "Result: " << r << "\n";
  28.             goto begin_cycle;
  29.         }
  30.         else if ( opr == "s" )
  31.         {
  32.             int r;
  33.             r=a-b;
  34.             cout << "Result: " << r << "\n";
  35.             goto begin_cycle;
  36.         }
  37.         else if (opr == "m" )
  38.         {
  39.             int r;
  40.             r=a*b;
  41.             cout << "Result: " << r << "\n";
  42.             goto begin_cycle;
  43.         }
  44.         else if ( opr == "d" )
  45.         {
  46.             int r;
  47.             r=a/b;
  48.             cout << "Result: " << r << "\n";
  49.             goto begin_cycle;
  50.         }
  51.         else if ( opr == "stop" )
  52.         {
  53.             goto end_cycle;
  54.         }
  55.         else
  56.         {
  57.             cout << opr << "is not an operator." << endl;
  58.             goto begin_cycle2;
  59.         }
  60.     } while (!done);
  61.     end_cycle:;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement