Liamza2314

Untitled

Jan 27th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. //i wrote all the other functions further up in the file, just testing with the add function for now
  2.  
  3. void add(int a, int x)
  4. {
  5.     int result = a + x;
  6.     cout << a << " + " << x << " is equal to " << result;
  7. }
  8.  
  9.  
  10.  
  11.  
  12. int main()
  13. {
  14.     srand(time(NULL));
  15.     cout << "Please select your operation: \n";
  16.     cout << "1. Addition \n2. Subtraction \n3. Multiplication \n4. Division \n5. Random Number \n0. Quit \n";
  17.     int option;
  18.     int first;
  19.     int second;
  20.     cin >> option;
  21.     do
  22.     {
  23.         switch (option)
  24.         {
  25.         case 1:
  26.             cout << "Please select the first number: ";
  27.             cin >> first;
  28.             cout << "Please select the second number: ";
  29.             cin >> second;
  30.             add(first, second);
  31.             break;
  32.         case 2:
  33.             cout << "Please select the first number: ";
  34.             cin >> first;
  35.             cout << "Please select the second number: ";
  36.             cin >> second;
  37.             sub(first, second);
  38.             break;
  39.         case 3:
  40.             cout << "Please select the first number: ";
  41.             cin >> first;
  42.             cout << "Please select the second number: ";
  43.             cin >> second;
  44.             multi(first, second);
  45.             break;
  46.         case 4:
  47.             cout << "Please select the first number: ";
  48.             cin >> first;
  49.             cout << "Please select the second number: ";
  50.             cin >> second;
  51.             divide(first, second);
  52.             break;
  53.         case 5:
  54.             int i;
  55.             cout << "Please enter the size limit for your random number: ";
  56.             cin >> i;
  57.             randomnum(i);
  58.             break;
  59.         case 0:
  60.             break;
  61.         }
  62.  
  63.     } while (option != 0);
  64. }
Advertisement
Add Comment
Please, Sign In to add comment