I am making a program that asks the user to choose a selection off of a menu, if the choose "1", an addition problem is displayed. If they enter -1, it should revert to the menu. I have been messing with my if structure and trying to figure out exactly how to do it, but I am stuck. (beginner c++) Right now, it simply says "Try Again!", as it should when the user enters any wrong number except -1.
Look at your if statements.
= is for assignment
== tests for equality. Replace your = operators with == in your if statements.
Also, you are not using braces { } to form blocks around your if statements. This will cause the if statement to only be associated with the first command after the if statement.
1 2 3 4
if (a)
b(); // b will be executed only if a is true
c(); // c will always be executed
d(); // d will always be executed
1 2 3 4 5
if (a) {
b(); // b will be executed only if a is true
c(); // c will be executed only if a is true
}
d(); // d will always be executed