Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please code in C The Assignment Write a program to play the game I'm thinking of a number. The program will play the role of

please code in C image text in transcribed
image text in transcribed
The Assignment Write a program to play the game "I'm thinking of a number." The program will play the role of the person who has the "secret" number. Your program should prompt the user to guess a number. If user's guess is incorrect, your program should say whether the guess is too high or too low. A sample run of your program might look like the following (with the user response in orange): Notes You must use a while loop in your program which terminates when the user guesses the correct number. Warn the user if he enters a number less than 1 or a number greater than 100. Use #define to define a constant secret that holds the number your program is "thinking" of (See for example math.s which used define to define a constant PI.) That way, if you change the secret number, you only have to change it in one place. Part 2 Include one of the following embellishments. Option 1: Instead of picking the same secret number each time, use a pseudo-random generator function. To do so, you must include the following header files: include sineb The first statement in your main function should set the random seed, as follows: The time function returns the number of seconds since 00:00:00 UTC, January 1, 1970. So, each run of the program (started more than I second apart) will set then random seed to a different valuc. Part 2 Include one of the following embellishments. Option 1: Instead of picking the same secret number each time, use a generator function. To do so, you must include the following header files: . include stabibb include it The first statement in your main function should set the random seed, as follows: The time function returns the number of seconds since 00:00:00 UTC, January 1, 1970. So, each run of the program (started more than 1 second apart) will set then random seed to a different value Now each call to the function randon) will return a "pseudo-random number as an ipt.value. To convert this into a number that is within the range of allowed numbers, use the & mod operator: n zandom) 1001 Then no matter what random returns, the variable n is assigned a number between 1 and 100. Option 2: Ask the user for the range of numbers from which to choose the secret number (instead of always choosing a number between 1 and 100). This will affect how you implement the other embellishments

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

=+8.8. Suppose that S = (0,1,2 ,... ], Poo =1, and f,o>0 for all i.

Answered: 1 week ago

Question

a valuing of personal and psychological privacy;

Answered: 1 week ago