+ 1
Where in real life scenario can do...while loop be applied?
7 Respuestas
+ 4
do { READING(); } while(BookHasPagesLeft());
get it?
+ 2
Ok, lets do another description:
You need the loop to loop once before testing the while-condition, and that is what a do...while-loop does. A common while-loop that doesn't have a do test that condition before the loops starts, and so it won't be executed if the condition fails initially.
Go to the bath room:
DO {
CheckDoorLock();
} WHILE (WAIT_WHILE_DOOR_IS_LOCKED());
after the loop is done then the WAIT_WHILE_DOOR_IS_LOCKED() has returned a false value, so it isn't locked anymore, thus, the whole loop ends.
So you could continue with code that does whatever you do in the bathroom.
Get it now? A loop that NEEDS one iteration before the actual test.
+ 2
Mr Anderz I think I now understand your example with book and reading.
+ 1
nope
+ 1
Speed limit is 120km/h on the free way.
do
{
Match Accelerator;
}while(speed < 120km/h)
@chikezie how far? drop me your contact.
+ 1
thanks guys now I get it
+ 1
@franky here is my Facebook account there I will give you my number http://www.facebook.com/barthopeters