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!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
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 ответов
+ 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