Problem 43

A Number-Guessing Game

Modify your incredibly stupid number-guessing game to actually pick a random number from 1 to 10 and have the user try to guess that. Tell them if they get it right or wrong, and if they get it wrong, show them what the random number was.

They will still only get one try.

I'm thinking of a number from 1 to 10.
Your guess: 3

Sorry, but I was really thinking of 4.
I'm thinking of a number from 1 to 10.
Your guess: 4

Sorry, but I was really thinking of 7.
I'm thinking of a number from 1 to 10.
Your guess: 2

That's right!  My secret number was 2!

◄ 42: Magic 8-Ball 44: Fortune Cookie ►



Adapted from ProgrammingByDoing.com
©2013 Graham Mitchell

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.