0

what is the deference between for,while and do while loop

16th Oct 2016, 6:44 PM
Javed
Javed - avatar
6 Réponses
+ 7
For and while loops are equivalent (though they have a different synthax), but you should generally use a for loop when you know how many times you will loop, and a while loop otherwise. With a do while loop, you are garanteed to loop at least once as the condition is checked at the end of the loop rather than at the beginning like in a for or while loop.
16th Oct 2016, 6:56 PM
Zen
Zen - avatar
+ 6
Do while works at least once. " While" loop works only if the condition of it is true.
16th Oct 2016, 6:57 PM
Remmae
Remmae - avatar
+ 3
while loop means like: "while this is happening, do this " for loops means: "for this to happen, do this " do while loop means:"do this, while this is happening " i hope that kinda helps :)
16th Oct 2016, 6:58 PM
Aquarius
Aquarius - avatar
+ 1
do while loop will run once even if the condition is false but in case of for & while loop condition should be true to run the loop. for loop is used when you know the number of times the loop will run & while is used when you don't know how many times the loop will run
17th Oct 2016, 11:52 AM
Kashish Gupta
Kashish Gupta - avatar
0
tnx
16th Oct 2016, 7:00 PM
Javed
Javed - avatar
0
For is the easy way And while is same but it checks before run Do while is opposite
21st Oct 2016, 2:08 PM
majuran thas
majuran thas - avatar