Question: why wont my computer played guessing game siphon through numbers between 100 and 200 to guess to properly. } if (choice == 'c' ) {

why wont my computer played guessing game siphon through numbers between 100 and 200 to guess to properly.

} if (choice == 'c')

{

int num = rand() % 101 + 100;

do

{

cout << "The computer's guess is " << num << endl;

if (num < random)

{

cout << "Sorry, your guess is too low, try again! ";

num += rand() % random;

}

else if (num > random)

{

cout << "Sorry, your guess is too high, try again! ";

num -= rand() % random;

} else

{

cout << "Congrats, you guessed the correct number," << random << endl;

break;

}

} while (num != random);

example output for c

Would you like to (p)play or watch the (c)computer play or (q)quit?

c

The computer's guess is 150

Sorry, your guess is too low, try again.

The computer's guess is 175

Sorry, your guess is too low, try again.

The computer's guess is 187

Sorry, your guess is too low, try again.

The computer's guess is 193

Sorry, your guess is too high, try again.

The computer's guess is 190

Sorry, your guess is too low, try again.

The computer's guess is 191

Sorry, your guess is too low, try again.

The computer's guess is 192

Congrats, you guessed the correct number, 192.

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!