+ 1

Where in real life scenario can do...while loop be applied?

12th Dec 2016, 4:30 PM
Peters Chikezie
Peters Chikezie - avatar
7 Respostas
+ 4
do { READING(); } while(BookHasPagesLeft()); get it?
12th Dec 2016, 4:56 PM
Anderz Lindberg
Anderz Lindberg - avatar
+ 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.
12th Dec 2016, 5:17 PM
Anderz Lindberg
Anderz Lindberg - avatar
+ 2
Mr Anderz I think I now understand your example with book and reading.
12th Dec 2016, 11:51 PM
Peters Chikezie
Peters Chikezie - avatar
+ 1
nope
12th Dec 2016, 5:11 PM
Peters Chikezie
Peters Chikezie - avatar
+ 1
Speed limit is 120km/h on the free way. do { Match Accelerator; }while(speed < 120km/h) @chikezie how far? drop me your contact.
12th Dec 2016, 8:15 PM
Franky BrainBox
Franky BrainBox - avatar
+ 1
thanks guys now I get it
12th Dec 2016, 11:49 PM
Peters Chikezie
Peters Chikezie - avatar
+ 1
@franky here is my Facebook account there I will give you my number http://www.facebook.com/barthopeters
16th Dec 2016, 4:59 PM
Peters Chikezie
Peters Chikezie - avatar