0

Give output without run this code.

https://code.sololearn.com/cKrBIVUFCQp4/?ref=app

17th Sep 2018, 12:08 PM
Rushil Koyani
Rushil Koyani - avatar
2 Respostas
+ 2
So what's your question? Why the y stays at 4? Because if the first expression in an logical or statement is already true, there is no need to execute the second expression. Either if the second one would be true or false, the condition is true anyways because of or-logic.
17th Sep 2018, 12:21 PM
Matthias
Matthias - avatar
+ 1
There is a short circuit evaluating in if condition. Evaluating from left to right. First ++x>6 is true so the second condition will not be evaluate ! Thus y remains 4.
17th Sep 2018, 12:28 PM
Károly Komjáti
Károly Komjáti - avatar