Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q3) Design a game Guess my number!. The player has three attempts to guess a hidden random number following the instructions: (4 marks) - Prompt

image text in transcribed

Q3) Design a game "Guess my number!". The player has three attempts to guess a hidden random number following the instructions: (4 marks) - Prompt a welcoming message, and explain that the player has three attempts to guess that number - Prompt a message to guess the hidden number that ranges between two values, for example, 1 and 10 - If the entered number is higher than the correct number then prompt a message such as "You are too high", and if the entered number is lower than the correct number then prompt a message like "You are too low". If the correct number is entered then prompt a message "Congratulations, you won!!". If the player was unsuccessful to guess the number then prompt a message "you Lose" - The player might be able to guess the number in the first or second trial, therefore, the program should stop after guessing the number although not all three trials were used. To achieve this goal use either: - Nested IF conditions to check both number of trials and if the user won or not In case you are using the WHILE statement, you need the BREAK statement to exit the WHILE loop if the correct number is guessed. For example, you can write inside the WHILE loop: if (entered_number == hidden_number) { break } - Use the following function to generate a hidden random number (num) between 1 and 10 : srand (time(NULL)); num =rand()%10+1; Have fun

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

What is the orientation toward time?

Answered: 1 week ago

Question

4. How is culture a contested site?

Answered: 1 week ago