Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create the program so that it implements a guessing game. The game works as foll

ID: 3623742 • Letter: C

Question

Create the program so that it implements a guessing game. The game works as follows: First, a (secret) random number in between 1 and 100, inclusive, is generated. Next, the user is prompted to enter a guess as to find the number is. If the guess is too high, an appropriate message asking for a lower guess should be printed. If the guess is too low, a corresponding message asking for a higher guess should be printed. In both of these cases, the user should enter another number. The game continues in this fashion until the user guesses the correct number. At this point in time, the game ends, and the program prints out a message stating the number of guesses it took the user to find the number.



Explanation / Answer

please rate - thanks

#include <stdio.h>
#include <time.h>
#include <conio.h>
#include <stdlib.h>
int main()
{int randomdigit,number,count=0;
srand(time(0));
randomdigit=(rand()%100)+1;
printf("Guess a number between 1 and 100 ");
do
     {printf("Enter number: ");
         scanf("%d",&number);
    if(number==randomdigit)
        printf("You guessed correctly! ");
    else
       if(number<randomdigit)
          printf("Too low, try again. ");
       else
          printf("Too high, try again. ");
    count++;
    }while(randomdigit !=number);
printf("It took you %d guesses to find the number ",count);
getch();
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote