Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

sk: You define an integer variable int x, and you assign x an arbitrary value you like. Then you are going to ask the user

sk: You define an integer variable int x, and you assign x an arbitrary value you like. Then you are going to ask the user to guess what x is. We let the user guess up to 10 times
image text in transcribed
In this assignment, you are going to turn in a single cpp file. Your goal is to design a little number guessing game. The purpose is to practice while and if. Therewl be only one single task and everythig can be written inside the main function Task: You define an integer variable int r, and you assign z an arbitrary value you like. Then you are going to ask the user to guess what r is. We let the user guess up to 10 times. (You can change 10 to whatever value you like or a user input. It does not matter.) Your program starts like this: 1. First the program prints "Guess the number:" 2. Then the user enters one number 3. Then the program prints "This is attempt 1, and the user guesses XXX", where XXX is the user's input. The guess was too s" or (3) "The guess was too large". should print This is attempt Y, and the user guesses ZZZ", depending on how many times 4. Then the program prints one of the three depending on the situation: (1) "Correct!", or (2) 5. If the user guesses correctly, end the game. Otherwise, repeat from step 1. Your progranm the user had tried before 6. If the user fails 10 times, the program prints "Fail the game!", and terminates the game

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

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago