- Iteration 1
- val is
-10 if ((-10 < 0) && (+10 >= 40))is false- so it doesn’t break out of the loop
*is printed- loop condition:
(-10 < 100)is true- so the loop continues
- val is then updated:
val = -val * 2val = +10*2 = 20
- val is
- Iteration 2
- val is
20 ifstatement short-circuits to false due to(20 < 0)being false- so it doesn’t break out of the loop
*is printed- loop condition:
(20 < 100)is true- so the loop continues
- val is then updated
val = -20*2 = -40
- val is
- Iteration 3
- val is
-40 if((-40 < 0) && (+40 >= 40))is true- so it breaks out of the loop before printing again
- val is
0
solved For loop returns ** value. Please explain [closed]