So I'm trying to complete as many practice c++ programs as I can because my programming class is extremely slow and we aren't learning anything.
I'm writing a program that asks the user a couple of math questions then outputs if they were right or wrong and at the end outputs their score.
However the problem I'm having is that if the user answers correctly both outcomes are outputted anyway. *Note: if the user answers correctly it still adds one to their score at the end.*
Also on line 19 and 30 there are two semicolons that have to be there so it won't throw errors but don't make sense (why does the else have to have them but not the if?). I wrote another program with some if then else statements and didn't have them there.
A suggestion, when you get this working, rather than hard-coding the questions and answers into the program, get the computer to generate a couple of random numbers, and perform the addition itself. That way, the questions will be more varied, and you don't have to pre-calculate the answer, let the computer do the work for you.
Oh ok, I get it, that makes more sense (with the no else condition) and chervil ok I'll start doing that now; is there a way to limit the random numbers it generates? I'm not trying to have 434 *234 to do in my head haha.
Maybe like fixed << setprecision(1) ? and change the int to a float variable?
why is your 'score' variable a float? Just make it an int since it will only go to 2..
i read somewhere that it's bad style to use the ++ incrementer for anything other than int, however you'll have to google it to find out why as i can't remember