Advertisement
ItzEdInYourBed

guess.cpp-fin

May 18th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main() {
  4.  
  5. int guess;
  6.  
  7. int tries = 0;
  8.  
  9. std::cout << "I have a number 1-10.\n";
  10. std::cout << "Please guess it: ";
  11. std::cin >> guess;
  12.  
  13. // Write a while loop here:
  14. while (guess != 8 && tries < 50) {
  15.  
  16. std::cout << "Wrong guess, try again: ";
  17. std::cin >> guess;
  18.  
  19. tries++;
  20. }
  21.  
  22.  
  23.  
  24.  
  25. if (guess == 8) {
  26.  
  27. std::cout << "You got it!\n";
  28.  
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement