Just a beginner! I've got a darts game between two players. I need to work out how many games player 1 wins and player 2 wins out of 1000 games if there is a coin flip and thereafter loser starts.
1 2 3 4
if (p1 < p2)
wins = 1 ;
else
wins = 0 ;
This is my code for if p1 has less throws than p2 then they win. I just don't know how to make them flip for it!
It's a little difficult to understand exactly what you're trying to do from what you've posted, however, I can guess at a couple of reasons you might get incorrect results. One being, under your if statements, you should use a brace to enclose code pertaining to the if statement. For example:
1 2 3 4 5
if()
{
statement;
statement;
}
This applies to else if and else statements as well. Otherwise only the first statement under the if statement will be evaluated as pertaining to the if statement.
Also, under an if statement, an else if or else statement should be used. In your code, you followed an if statement by another if statement, when the second if should be either an else if or an else.