Before:
// Playing a guessing game
void playGame()
{
userGuess();
}
void userGuess()
{
// Variable declarations
int guess;
// Have the user guess a number 1-99
cout << "Enter your guess of the number (1-99)" << endl;
cin >> guess;
// Have the computer randomly generate a number and decide the winner
computerGuess( guess );
}
void computerGuess( int userGuess )
{
// Computer generates a random number (1-99)
int computerGuess = rand() % 99 + 1;
// Declare winner
declareWinner( userGuess, computerGuess );
}
void declareWinner( int userGuess, int computerGuess )
{
if( userGuess == computerGuess )
cout << "You guessed correctly" << endl;
else
cout << "Sorry, your guess was incorrect" << endl;
}