0
[SOLVED] Why is 16 not printed in this code when breaking is only when i == 32?
Tried while loop with two if statements . original value of i = 1. then i = i*2. to continue till i <= 10, then breaking at i = 32. result was 2, 4, 8, breaking, finished.
3 Réponses
+ 7
If you are referring to the code below:
https://code.sololearn.com/cdhCygSbUI6H/?ref=app
It only prints when i < 10, so the last is 8
When it reaches 16 it does not meet the first condition (as 16 > 10) and goes without doing anything, back to the beginning of the loop. Then it gets doubled to 32 and breaks. Anything that stands after the break statement cannot be executed.
+ 1
Thanks a lot Kuba for the explanstion. now it's clear.
0
can you share or copy the code maybe ? wild guess is that you continue or dont print anything after i <= 10