If I let the init & decrement statements empty, how does the for loop will work?! | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

If I let the init & decrement statements empty, how does the for loop will work?!

21st Jul 2016, 6:20 PM
Last Day
Last Day - avatar
3 Respostas
+ 1
If in your loop something else modifies the variable to the point where the condition isn't verified anymore, your loop will end at this point. Otherwise, if the condition can never be untrue, it'll running indefinitely and you'll have a running error
21st Jul 2016, 6:30 PM
Aceitunarabe
Aceitunarabe - avatar
+ 1
If you use only the condition check in a for loop you will have exactly the same behaviour as in a while loop... It will run until that condition if false or it will not run at all if the condition is false at the beginnig of the loop... Hope it helped
22nd Jul 2016, 10:09 AM
Nelson Urbina
Nelson Urbina - avatar
0
thanks guys, I get it šŸ‘Œ
22nd Jul 2016, 1:52 PM
Last Day
Last Day - avatar