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 21:00
Kirk found a local community college with a two-year program and he is comparing the cost with that of an out-of-state two-year school. what is the expected total cost for one year at the local community college if kirk lives at home? what is the expected total cost for one year at the out-of-state school if kirk lives on campus?
Answers: 2
question
Computers and Technology, 22.06.2019 21:00
The average cost of one year at a private college in 2012-2013 is $43,289. the average grant aid received by a student at a private college in 2012-2013 is $15,680.   what is the average student contribution for one year at a private college in 2012-2013?
Answers: 3
question
Computers and Technology, 23.06.2019 10:50
The volume v and paper surface area a of a conical paper cup are given by where r is the radius of the base of the cone and h is the height of the cone. a. by eliminating h, obtain the expression for a as a function of r and v. b. create a user-de ned function that accepts r as the only argument and computes a for a given value of v. declare v to be global within the function. c. for v ! 10 in.3 , use the function with the fminbnd function to compute the value of r that minimizes the area a. what is the corresponding value of the height h? investigate the sensitivity of the solution by plotting v versus r. how much can r vary about its optimal value before the area increases 10 percent above its minimum value?
Answers: 1
question
Computers and Technology, 24.06.2019 16:30
You may see the term faq on websites which stands for frequently asked questions this is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation ken has dipped many dark chocolate marshmallows (which you remember the metric system distance units in decreasing order: kilometers, hectometer, decameter, centimeter, millimeter) is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation !
Answers: 1
You know the right answer?
Bool checkforwin(int guess, int answer)
{
if (answer == guess)
{
cout < &...
Questions
question
Chemistry, 20.02.2020 23:54
question
Mathematics, 20.02.2020 23:54
question
Mathematics, 20.02.2020 23:55
Questions on the website: 13722360