+ 2
Where can we apply this do...while loop and other loops??
10 Answers
+ 1
Oh
+ 1
Well, in different codes, i.e. Counter from 1 to 10.
+ 1
haven't gotten you megacreator458
+ 1
do while is used when you want to execute something one time and after that execute it again if the condition is true, for example :
do{x++;}while(x < 5)
will execute x++ one time.
then it will check condition of while and execute the loop again if it is true.
0
What are you talking about
0
what about other loops but still I want to know , where to apply them and not how.!
0
checking conditions for n times..and for iteration..
0
you can apply them when u need a part of code to execute 'n' times. same goes for the other loops. that's why they're called "loops"
0
Do while executes the block of code atleast once even if ur condition results in false
0
If you don't know in advance how many times you will need to run a loop, but you know it needs to run at least once, use do/while.
An example would be if you had a program flipping a virtual coin until you get heads. You don't know how many times it will need to run, but it has to run once and then run while you are getting tails.