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, 22.06.2019 03:40
Hello my name is mihai and i need your : )i have to do a python project in computer science and iโ€™m really busy with my mocks this period of time besides this iโ€™m not good at coding so could someone pls pls pls sort me out ? i actually beg ; ))
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
Why would a programmer use the logical operator and in an if statement? a: when an action is to be taken that requires both conditions to be falseb: when an action is to be taken that requires both conditions to be truec: when an action is to be taken that requires the first condition to be falsed: when an action is to be taken that requires the second condition to be truei took the test and the answer is b.
Answers: 3
question
Computers and Technology, 23.06.2019 22:30
You draw two cards from a standard deck of 52 cards, but before you draw the second card, you put the first one back and reshuffle the deck. (a) are the outcomes on the two cards independent? why?
Answers: 3
question
Computers and Technology, 24.06.2019 15:30
How do i change the size of my bookmarks in my bookmarks bar in google chrome? ? plz hlp me
Answers: 2
You know the right answer?
Bool checkforwin(int guess, int answer)
{
if (answer == guess)
{
cout < &...
Questions
question
Spanish, 13.10.2020 01:01
Questions on the website: 13722361