Site hosted by Angelfire.com: Build your free website today!

Bonus #14

C++
K. Dzwonkiewicz

Bonus Number 14

Number Guess

 

                                                       

Ask a person to guess a number that the computer has thought of between 1…100

 

Use a do…while or a while

 

Count how many guesses it takes to get the computer’s number.

 

If they take more than 8 guesses the process should stop.

   Display the message…Sorry only 8 guesses

 

You will need to use the random statement…

       Number = random(100) + 1;

 

Sample run….

 

Please guess my number. . .it is in the range 1. . .100

Guess #1: 50

    Too high

Guess #2:25

    Too low

Guess #3:37

    Too low

Guess #4:43

    Too low

Guess #5:46

    CORRECT! You guessed my number in 5 attempts.