int p = 7; if(++p > 10 && p++ > 11) p++;
I know the output of p after the execution is 8 but I do not know why.
code would execute as
(8 > 10 && 8 > 11 ) this is false so the p++ at the end would not be executed. I'm not sure what I'm doing wrong here. I have a quiz this week dealing with these types of problems and this is one of the questions on the practice quiz. The answer is 8 but I would like to know why so that I better understand what I'm doing.
Playing around with the code I see that the 8 is coming from within the if statement and not after. I deleted the p++ after the statement and I still get an output of 8. How does this work?
Found out where I was messing up.
The ++p at the beginning of the statement was making the p=8, everything after that was false.