Question: -Please write the solustion as C++ program . The following program randomly generates an integer greater than or equal to 0 and less than 100.
-Please write the solustion as C++ program .
The following program randomly generates an integer greater than or equal to 0 and less than 100. The program should prompt the user to guess the number. If the user guesses the number correctly , the program outputs the an appropriate message. Otherwise, the program checks whether the guessed number is less than the random number, he program outputs the message your number is lower than the number. Guess again. Otherwise the program will prompt your number is higher than the number. Guess againThe program prompt the user to enter an another number until the user enters the correct number.
Hint:
To generate a random number, you should include cstdlib heder file and use function rand()
To generate different random numbers each time the program is run you need to use srand() which acts as the seed for the algorithm. By specifying different seed values, each time the program is executed, the function rand will generate a different sequence of random numbers. To specify a different seed, you can use use the function time of the header ctime,
Srand(time(0));
Num = rand()%100
Int number; // random
Int guess ; // from user
Bool isGuessed;
While is not guessed
{
Enter an integer number
Cin >> guess;// from user
You are right
Number to small
Number too big
}
The example for flag controlled loop
Flag controlled loops - A bool variable is defined and initialized to serve as a flag. The while loop continues until the flag variable value flips (true becomes false or false becomes true). In the following example the user is asked to enter numbers at the keyboard which are added together. To stop the addition the user enters a negative number.

// Flag controlled loop #1 nclude
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
