If Statement not working C++

Hello. When I play my game and enter the correct code, it says: “Code is invalid.”, but I entered the correct code. Even when I enter the wrong code, It says “Code is invalid.”. I think the problem may be with the If Statement. Here is the code:

The code where you set up your guess variables…ie GuessSum = Guess A + Guess B etc… where you declare them, they’re all 0 - so those variables will always be zero. What you need to do is move that Guess sum and product code to the bottom, after the user has filled out the “Guess” variables. Or, declare them at the top, and then do the calculation after the user has filled out their guesses, just before the IF statement.

Thanks! It works.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.