Advertisement
Guest User

random number generator

a guest
Jan 24th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <time.h>
  7.  
  8. using namespace std;
  9.  
  10. int main() {
  11.  
  12. int divisor{}, play{}, number{}, guess{};
  13.  
  14. cout << "I've picked a number between 1 and 50 that has " << divisor << " divisor(s). ";
  15. divisor = rand() % 50 + 1;
  16.  
  17.  
  18. cout << "\n Guess the number: ";
  19. cin >> guess;
  20. srand(time(NULL));
  21. guess = rand() % 50 + 1;
  22.  
  23. if (guess < number)
  24. {
  25. cout << "\nToo low!" << endl; // so close! :c
  26. }
  27. else if (guess > number)
  28. {
  29. cout << "\nToo high!" << endl; //oh no :c
  30. }
  31. else if (guess = number)
  32. {
  33. cout << "\n You got it!! " << endl; // UwU OwO im so pwoud!
  34. } while (guess != number);
  35.  
  36.  
  37.  
  38.  
  39.  
  40. cout << " Play again? [y/n] " << endl;
  41. cin >> play;
  42.  
  43. if (play == 'y')
  44. {
  45.  
  46.  
  47. }
  48. else if (play == 'n')
  49. {
  50.  
  51.  
  52. }
  53.  
  54.  
  55.  
  56.  
  57.  
  58. system("pause");
  59. return 0;
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement