Question: 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
 sk: You define an integer variable int x, and you assign

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

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!