Does it work?
With improved indentation, and some additional notes:
Code:
result = Play(answer);
int Play(int answer)
{
int numGuesses = 0;
int guess = 0;
int result = 0; // Variable not needed (read on)
do
{
guess = GetGuess();
CompareGuess(guess, answer); // Are you comparing the guess with
// the answer here?
if(guess == answer) // ... or here?
{
result = 1; // You can just return 1 here...
}
return result; // ...instead of using this variable
numGuesses = numGuesses +1;
} while( numGuesses < MAXGUESSES);
if (guess != answer) // if the number of guesses have already
{ // been used up with no correct result,
result = 0; // you don't need this extra check here.
} // Just return 0 after the loop.
return result; // Then you wouldn't need this line, either.
}