Help me please geting always same output You Lose

I may be missing something simple, but it all looks in order. Try printing(std::cout) the GuessSum, GuessProduct, CodeSum, and CodeProduct to make sure they actually match and nothing funny is going on would be my thoughts.

1 Like

I haven’t tested the code, and it looks fine to me.

Maybe the error is related to how the answer is typed?

should be entered like this: 4 3 2 (note the space)

or number followed by enter.
4
3
2

I’ve had a read-through of your code and cant see an issue either.
The suggestions above look good, i cant see how it could be anything else beyond an issue with ‘order of operations’ which itself looks fine too but sometimes when i’m having a fight with c++ maths I force the order of operations with ‘()’ surrounding my logic;
eg

if(    (true==true) && (true==true)   )

Hi,

your error is on line 30:

int GuessSum = GuessA + GuessA + GuessC;

You added GuessA two times!

This is right:

int GuessSum = GuessA + GuessB + GuessC;

It often helps to stop, walk around and drink a glass of water and then coming back to the project.

Cheers!

2 Likes

This is sound advice. I actually find this works with art too.

When doing a larger project I find that my pictures can look like a mess of lines and squiggles. But when I walk away for awhile and then come back, I can see the whole thing in perspective.

My head was getting stuck in the details and could not see the forest through the trees as the saying goes. Or in this case the program through the separate lines of code.

1 Like

Privacy & Terms