Guess My Number - A Game
Hello user! Think of a number between 1 and 50. Let’s see if I can guess it!
Ready? Enter y (yes) or n (no): y
Is it 25? Enter y (yes), h (go higher) or l (go lower): l
OK! Is it 12? Enter y (yes), h (go higher) or l (go lower): h
OK! Is it 18? Enter y (yes), h (go higher) or l (go lower): h
OK! Is it 21? Enter y (yes), h (go higher) or l (go lower): y
Yay! I guessed it in 4 guesses… Yes, I’m THAT awesome!
Write a C++ program to create the above game. You may also wish to personalize it by having the user enter his/her own name first to the computer can talk to an individual instead of just “user.”
Use a function, nextGuess() to return the computer’s – uh – next guess. Do not use global variables.
The prototype for the function will look something like this:
int nextGuess (/*there may possibly be parameters here*/)