Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

Do I really need this item?

Answered: 1 week ago