Need Help
Jul 21, 2015 at 1:48pm UTC
If I have a (Y/N) statement where I have both "y" and "n" as answers, but to be correct, you can't have a wrong answer, how can I have it to where if it sees an "n" answer (all of the correct answers are y), that it goes to Not_Correct()?
This is what I have so far, but if I answer all questions with "y" (the correct answers), it takes me to Not_Correct().
I'm very new to this, so any help is appreciated.
1 2 3 4 5 6 7 8 9 10 11 12
if (correct = 0 || 1) {
Not_Correct();
return (0);
}
else
if (correct = 0) {
Not_Correct();
}
else
if (correct = 1) {
Correct();
}
Jul 21, 2015 at 1:55pm UTC
The equality operator is == and the assignment operator is =
If I declare a variable:
I can assign a value to it:
The 'number' variable now holds the value 10. I can check that this is correct with use of the equality operator:
1 2 3 4
if (number == 10)
Correct();
else
Not_Correct();
Does that help?
Jul 21, 2015 at 2:21pm UTC
Still not working :\.
Jul 21, 2015 at 2:23pm UTC
Please show more of your code where does the 'correct' variable get it's value and what is the value in your test scenario?
Jul 21, 2015 at 2:39pm UTC
also note that if you want to do an OR, that this is wrong:
1 2
if (correct = 0 || 1)
...
You would need to do something like this:
1 2
if (correct == 0 || correct == 1)
...
Jul 21, 2015 at 2:41pm UTC
Never mind, that fixed it, I just didn't understand at first, sorry.
Thank you for the help.
Topic archived. No new replies allowed.