Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <ctime>
  4. #include <cstdlib>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. srand (time(NULL));
  10. // Variable declaration
  11.  
  12. int guess;
  13. const int minimum = 1;
  14. const int maximum = 10;
  15. int range = maximum - minimum + 1;
  16. int num = rand() % range + minimum;
  17. int amountOfGuesses = 0;
  18.  
  19. do{
  20. cout << "Pick a number between 1-10: " << endl;
  21. cin >> guess;
  22. amountOfGuesses++;
  23. if (guess<num)
  24. {
  25. cout << "Too low modafucka" << endl;
  26. }
  27. if (guess>num)
  28. cout << "Too high hahaaaha" << endl;
  29. }while(guess!=num);
  30.  
  31.  
  32.  
  33. cout << "<<<CONGRATULATIONS>>>! You won!" << endl;
  34. cout << "It took u " <<amountOfGuesses<< " tries" << endl;
  35.  
  36. system("pause");
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement