Pls, what instances should for or while or do while loop be used. As in what differentiate their uses | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Pls, what instances should for or while or do while loop be used. As in what differentiate their uses

12th Jun 2018, 11:18 AM
Favor Mofadeke Salako
2 Answers
+ 1
Use "while" when you don't know how many iterations you need. Use "for" when you know how many times it should be looped. "do while" is for those awkward situations when you want while loop, but you still need to run the loop at least once. It's pretty rare.
12th Jun 2018, 11:33 AM
BlazingMagpie
BlazingMagpie - avatar
0
Thank you
12th Jun 2018, 1:27 PM
Favor Mofadeke Salako