+ 3
How come this program produces a output of 52?
INT x=0; y=0; for(INT z=1,z<5;z++) { if((++x>2) && (++y>1)) { x++; } } System.out.println(x+""+y);
2 odpowiedzi
+ 4
It would produce error. There's many syntax errors here.
Disregarding that,
z = 1.
Is ++x > 2?
no, x = 1, z = 2
Is ++x > 2
no, x = 2, z = 3
Is ++x > 2
Yes, x = 3
Now we can check y
Is ++y > 1
no, y = 1, z = 4
Is ++ x > 2
Yes, x = 4
Is ++y > 1
Yes, y = 2
x++, z = 5
x = 5
5 < 5 is false, so loop stops. (Using z here)
Output: 52
+ 3
Errors removed
https://code.sololearn.com/cgvLYDQ4KQIu/?ref=app