When we use "for" and "while" and "do while"?🤔 | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

When we use "for" and "while" and "do while"?🤔

24th Nov 2017, 3:25 PM
mr.yavari
mr.yavari - avatar
4 Antworten
+ 2
you use for when, for example checking the length of an array, because the length of the array is finite. you use while when, you dont know the length and you check whether some conditions are met in order to loop again do while will perform a least one time before ending.
24th Nov 2017, 3:58 PM
Dmitrii
Dmitrii - avatar
+ 1
for: when you know the times the loop is going to be active while: when you don't know for how long your loop will be active do while: when you need your loop to be active for at least one time
24th Nov 2017, 3:51 PM
Dmitrii
Dmitrii - avatar
0
Can you explain more?
24th Nov 2017, 3:53 PM
mr.yavari
mr.yavari - avatar
0
tnx 😘😆
24th Nov 2017, 4:00 PM
mr.yavari
mr.yavari - avatar