// Query user to guess a number and check it against the correct number. #include #define MAXGUESSES 3 #define CORRECTNUM 7 int main(void) { int guess, numGuesses = 0; do { printf("Guess a number between 0 and 9. You have %d more guesses.\n", (MAXGUESSES-numGuesses)); scanf("%d", &guess); // read user input numGuesses++; } while ( (numGuesses < MAXGUESSES) & (guess != CORRECTNUM) ); // do loop checks the condition after the first iteration if (guess == CORRECTNUM) printf("You guessed the correct number!\n"); else printf("You are out of attempts!\n"); }