0

is do...while(condition) more advantageous than while(true)...if(!condition)break?

I never use do...while because I can use if()break to make a loop (or part of one) run at least once. would using do...while for efficiency be worth the lack of modifiability?

31st Aug 2016, 5:33 AM
lapin16
3 Answers
+ 5
do while loop is good if you want to execute a block of codes at least once and then only check the condition. It's normally used for data validation to ask user input and then check if user input the correct data.
31st Aug 2016, 1:26 PM
Fung
Fung - avatar
+ 1
Actually do while conditions is better in palace where u want to give the demo then u should use the do while
6th Sep 2016, 9:11 AM
Imran Bashir
Imran Bashir - avatar
0
you may also you for loop and put your condition in the middle of the for loop.
2nd Sep 2016, 7:41 PM
Erwin Mesias
Erwin Mesias - avatar