+ 3

Are do-while loops frequently used in real-world programming?

31st Jul 2016, 10:24 AM
Aidar Sadykov
Aidar Sadykov - avatar
4 ответов
+ 7
very rarely (if at all). I find that a while loop works in most cases. this is because more often than not the loop is performing an action on a predefined variable in which case the variable doesn't need to be defined by the 'do' part of a 'do while' loop. Some extra details on ALL loops: How I like to remember what loop I should be using is by asking myself if I want to perform a function repeatedly until some condition is met (while loop) or if I am performing an action on a collection (foreach loop), or if I'm using the index value of a collection to perform an action (for loop)
1st Aug 2016, 10:42 AM
Mike
Mike - avatar
+ 1
Use it when you expect user to enter a value. If user-entered value conforms to program logic, then cycle ends there, otherwise cycle repeats.
25th Nov 2016, 11:19 AM
Slava Kotelnikov
Slava Kotelnikov - avatar
0
Иначе говоря, используй если требуется хотя бы один ввод.
25th Nov 2016, 11:20 AM
Slava Kotelnikov
Slava Kotelnikov - avatar
0
when needed loop run at least one time conditions true or false not matter
16th Dec 2016, 12:43 PM
Hejbullah Afsari
Hejbullah Afsari - avatar