Advertisement
BojidarDosev

comp generates rand num betw 1 and 20 and you guess it

Mar 14th, 2024
603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int num1, num2;
  9.  
  10.     cout << "your number is: ";
  11.     cin >> num2;
  12.  
  13.     srand(time(NULL));
  14.     num1 = rand() % 20 + 1;
  15.  
  16.     cout << "computer number is: " << num1 << endl;
  17.  
  18.     if (num2 == num1)
  19.     {
  20.         cout << true;
  21.     }
  22.     else cout << false;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement