Write an application that plays \"guess the number\" as follows: Your program ch
ID: 3855096 • Letter: W
Question
Write an application that plays "guess the number" as follows: Your program chooses the number to be guessed by selecting a random integer in the range 1 to 1000. The application displays the prompt Guess a number between 1 and 1000. The player inputs a first guess. If the player's guess is incorrect, your program should display Too high. or Too low. to help the player "zero in" on the correct answer. The program should prompt the user for the next guess. When the user enters the correct answer, display Congratulations. You guessed the number!, and allow the user to choose whether to play again.Explanation / Answer
#incclude<stdio.h>
int main() {
int number,guess;
srand(time(null));
number = rand() % 1000 + 1;
do {
printf("Guess the number: ");
scanf("%d",&guess);
if (guess < number)
printf("Too low ");
else if (guess > number)
printf("Too high ");
}while(guess != number);
printf("Congratualtion. The number was %d", number);
}
This code in C will serve your purpose... I hope this helped you.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.