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

1. Write a program that plays the game of“guess the number” as follows: your pro

ID: 3614971 • Letter: 1

Question

1.     Write a program that plays the game of“guess the number” as follows: your programchooses the number to be guessed by selecting an integer at randomin the range 1 to 100. The program then types:

Ihave a number between 1 and 100.

Canyou guess my number?

Please, type your first guess:

Theplayer then types a first guess. The program responds withone of the following:

-       If the player guessed thenumber:          Excellent! You guessed the number!

-       If the player’s guesswas too high:         Too high. Try again:

-       If the player’s guesswas toolow:          Too low. Try again:

If the player’s guess is incorrect, your program shouldloop until the player finally gets the number right. Yourprogram should keep telling the player Too high or Too low to helpthe player “zero in” on the correct answer.

Example:

Ihave a number between 1 and 100.

Canyou guess my number?

Please, type your first guess:   50

Toohigh. Tryagain:            25

Toolow. Tryagain:             37

Toolow. Tryagain:             44

Toohigh. Tryagain:            41

Excellent! You guessed the number!


After the user guessed the number correctly, your program shouldask the user if s/he would like to play again. The only twovalid answers should be ‘y’ for yes and ‘n’for no. If the user wishes to play again, your program shouldgenerate a different number between 1 and 100 to start thegame.

Example:

Ihave a number between 1 and 100.

Canyou guess my number?

Please, type your first guess:   50

Toohigh. Tryagain:            25

Toolow. Tryagain:             37

Toolow. Tryagain:             44

Toohigh. Tryagain:            41

Excellent! You guessed the number!

Would you like to play again (y or n)? y

Ihave a number between 1 and 100.

Canyou guess my number?

Please, type your first guess:   50

.

.

.

Explanation / Answer

please rate - thanks #include #include #include #include int main() {int randomdigit,number=-1; char again='y'; srand(time(0)); while(again=='y') { randomdigit=(rand()%100)+1; printf("Guess a number between 1 and 100 "); while(randomdigit !=number)      {printf("Enter number: ");         scanf("%d",&number);     if(number==randomdigit)         printf("You guessedcorrectly! ");     else        if(number