After:
// Playing a guessing game
void playGame()
{
declareWinner( userGuess(), computerGuess() );
}
int 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
return guess;
}
int computerGuess()
{
// Computer generates a random number (1-99)
int computerGuess = rand() % 99 + 1;
return computerGuess;
}
void declareWinner( int userGuess, int computerGuess )
{
if( userGuess == computerGuess )
cout << "You guessed correctly" << endl;
else
cout << "Sorry, your guess was incorrect" << endl;
}