BrU32

C++ Guess Random # Guessing Game Hotter/Colder SRC V2

Mar 2nd, 2017
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. using namespace std;
  5. int rando, guess;
  6. int count = 1;
  7. int Attm =0;
  8. int main(){
  9. srand (time(0));
  10. rando = 1 + rand()% 100;
  11. cout << "Type a number between 1 and 100, hope you get it! " <<"\n";
  12. cin >> guess;
  13. while (guess != rando){
  14. if (guess < rando){
  15. Attm++;
  16. cout << "You guessed very low! Try again: " << "\n";
  17. cin >> guess;
  18. }
  19. else if (guess > rando){
  20. Attm++;
  21. cout << "You guessed very high! Try again: " << "\n";
  22. cin >> guess;
  23. }
  24. if (guess == rando){
  25. Attm++;
  26. cout << "You got it correct!" << "\n";
  27. cout << "In "<< Attm << " Tries!!" << endl;
  28. }
  29. //return 0;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment