Dice Game - Ending loop trouble

Hey, im trying to fix this code I wrote, its a simple dice rolling game but im having a problem trying to end the loop. I want it to end if balance = 0 or if user inputs -1.


When I input -1 it stills asks me one more time before ending the program, and it wont end if bank balance is 0.
Last edited on
What type of variables are "bet"and "bank"?

Also, you could just do if(gameRound()) and you wouldn't need that extra variable. ;)
Last edited on
They are float.

Didnt know about that if (function name), thanks ;)
Try while(bet > 0.0 && bank > 0.0)
Changed it to a do/while, and the if statement and it works now, thanks.
You shouldn't compare floats for equality because in the representation you have trunc error
Either use an epsilon fabs(a - b) < epsilon or try to work around with integers (think in cents)
Topic archived. No new replies allowed.