Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C++ program. Define an integer variable and give it a value of 1- 100. Ask the user to guess this number, compare the sizes of the two numbers, and present the results to the user until the guess is c
C++ program. Define an integer variable and give it a value of 1- 100. Ask the user to guess this number, compare the sizes of the two numbers, and present the results to the user until the guess is c
C++ program. Define an integer variable and give it a value of 1- 100. Ask the user to guess this number, compare the sizes of the two numbers, and present the results to the user until the guess is correct. # include & ltiostream & gt

# include & lttime.h & gt

Use namespace std

int main()

{

int num,a;

srand(time(0));

num = rand()% 100+ 1; // 1~ 100 randomly generates a number.

cout & lt& ltnum & lt& ltendl

While (number)

{

Cout & lt& lt user entered a number: ";

CIN & gt; & gta;

If (a> number)

{

Cout & lt& lt "greater than the number of troops" < & ltendl

}

else if(a & lt; Numbers)

{

Cout & lt& lt "less than the given number" endl

}

other

{

num = num-a;

Cout & lt& lt "Bingo!" & lt& ltendl

}

}

Returns 0;

}

Hmm ~ ~ ~ ~ Why did you give a satisfactory answer? I cried. Look at me ~ ~ ~