Question: Please use C language. Note that in the code above, it is assumed that int-typed variable x is used to store the magic number and

 Please use C language. Note that in the code above, it

Please use C language.

Note that in the code above, it is assumed that int-typed variable x is used to store the magic number and you will need to include both stdlib.h and time.h in the preprocessing directives in order to use these two lines. Design and implement the program.

Question 7 In this question, you are to write a program that plays a game with the user. When the program is executed, it first generates a random integer between 1 and 100 (inclusive). We will call this number the magic number. The program then keeps prompting the user to enter an integer guessing this magic number until the user guesses it correctly. More specifically, if the user enters a number that is smaller than the magic number, the program prints a message saying "Your number is too smal and prompts the user to guess again; if the user enters a number that is larger than the magic number, the program prints a message saying "Your number is too large" and also prompts the user to guess again. If the user enters a number that is eractly the magic number, the program prints a message saying "You got it!". The program also counts how many times it takes for the user to guess the magic number correctly, and after the user guesses the number correctly, it prints a final message and erits. If it takes 8 or more times for the user to guess the number correctly, the final message is "The way you guess the number is not too Smart. You lose!"; otherwise the final message is "Good job. You win!". 9 To generate the magic number, you can use the following lines of code srand (time (NULL); x-rand ( )% 100+1; 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!