Advertisement
Guest User

tesaaa

a guest
Aug 25th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main(void) {
  6. srand(time(NULL));
  7. int r = 5;
  8. int correct = 5;
  9. int guess;
  10. int counter = 0;
  11. int i=0;
  12. printf("Guess my number! 1 - 10");
  13. for (i;i==5;i++){
  14. if(counter == 5){
  15. printf("Limit 5x");
  16. break;
  17. }
  18.  
  19. scanf("%d", &guess);
  20.  
  21. if(guess < correct ){
  22. counter++;
  23. printf("Your guess is too low. Guess again. ");
  24. }else if(guess < correct){
  25. counter++;
  26. printf("Your guess is too high. Guess again. ");
  27. }else if(guess == correct){
  28. counter++;
  29. printf("You guessed correctly in %d tries! Congratulations!\n", counter);
  30. correct = 1;
  31. }
  32. }
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement