subject

Bool checkforwin(int guess, int answer)
{
if (answer == guess)
{
cout < < "you're right! you win! " < < endl;
return true;
}
else if (answer < guess)
cout < < "your guess is too high." < < endl;
else
cout < < "your guess is too low." < < endl;
return false;
}
// the play function takes as input two player objects.
void play(player & player1, player & player2) {
int answer = 0, guess = 0;
answer = rand() % 100;
bool win = false;
while (! win)
{
cout < < "player 1's turn to guess." < < endl;
guess = player1.getguess();
win = checkforwin(guess, answer);
if (win) return;
cout < < "player 2's turn to guess." < < endl;
guess = player2.getguess();
win = checkforwin(guess, answer);
}
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 15:20
In a game with three frames, where will the objects on layer 1 appear? a. next to the play area b. in the middle of the game c. behind everything else d. in front of everything else
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
Write a program that prints the day number of the year, given the date in the form month-day-year. for example, if the input is 1-1-2006, the day number is 1; if the input is 12-25-2006, the day number is 359. the program should check for a leap year. a year is a leap year if it is divisible by 4, but not divisible by 100. for example, 1992 and 2008 are divisible by 4, but not by 100. a year that is divisible by 100 is a leap year if it is also divisible by 400. for example, 1600 and 2000 are divisible by 400. however, 1800 is not a leap year because 1800 is not divisible by 400.
Answers: 3
question
Computers and Technology, 23.06.2019 20:30
If chris has a car liability insurance, what damage would he be covered for
Answers: 1
question
Computers and Technology, 23.06.2019 21:20
In microsoft word, when you highlight existing text you want to replace, you're in              a.  advanced mode.    b.  automatic mode.    c.  basic mode.    d.  typeover mode
Answers: 1
You know the right answer?
Bool checkforwin(int guess, int answer)
{
if (answer == guess)
{
cout < &...
Questions
question
Geography, 19.10.2019 23:50
question
Computers and Technology, 19.10.2019 23:50
question
Mathematics, 19.10.2019 23:50
question
Spanish, 19.10.2019 23:50