alansam

Adding game.

May 26th, 2021 (edited)
386
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include<iostream>
  3.  
  4. using namespace std;
  5.  
  6. int func(void) {
  7.   int b;
  8.   int c;
  9.   int r;
  10.   cout << " hello enter a number " << endl;
  11.   cin >> b;
  12.   cout << " enter another number " << endl;
  13.   cin >> c;
  14.   r = b + c;
  15.   return r;
  16. }
  17.  
  18. int main(int argc, char * argv[]) {
  19.   int t(0);
  20.   cout << " Hello world would you like to play a little game? if so type 0 if no 1 " << endl;
  21.   cin >> t;
  22.   if (t == 0) {
  23.     int r = func();
  24.     cout << " the result is " << r << endl;
  25.   }
  26.   else if (t == 1) {
  27.     cout << " thanks for typing 1 bye " << endl;
  28.   }
  29.   else {
  30.     cout << " see you later!" << endl;
  31.   }
  32.  
  33.   return 0;
  34. }
  35.  
RAW Paste Data