1
0

guess.c 519 B

12345678910111213141516
  1. /* guess.c -- an inefficient and faulty number-guesser */
  2. #include <stdio.h>
  3. int main(void)
  4. {
  5. int guess = 1;
  6. printf("Pick an integer from 1 to 100. I will try to guess ");
  7. printf("it.\nRespond with a y if my guess is right and with");
  8. printf("\nan n if it is wrong.\n");
  9. printf("Uh...is your number %d?\n", guess);
  10. while (getchar() != 'y') /* get response, compare to y */
  11. printf("Well, then, is it %d?\n", ++guess);
  12. printf("I knew I could do it!\n");
  13. return 0;
  14. }