+ 3
Are do-while loops frequently used in real-world programming?
4 Respostas
+ 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)
+ 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.
0
Иначе говоря, используй если требуется хотя бы один ввод.
0
when needed loop run at least one time conditions true or false not matter