0

exit and entry-control loop

Is the following two statements false because it is exactly opposite? 1. The "while" loop is an exit-control loop 2. The "do while" loop is an entry-control loop I know that the while loop tests the loop condition at the top of the loop; the condition has to be true for it to loop. In this sense, is it correct to say that the while loop would be an entry-control loop instead (and exit-control for the do while loop)?

24th Jul 2020, 7:26 AM
Solus
Solus - avatar
2 Answers
0
You are indeed correct. Both statements are false. Entry-controlled loops (examples are for loop and while loop) needs to be verified first befor executed. On the other hand, Exit-controlled loops(do-while loop), will be executed first before checking the while loop(terminator)
24th Jul 2020, 7:39 AM
Jay Gilbert Garzon
Jay Gilbert Garzon - avatar
0
If the condition in the for loop/while loop is not satisfied, the execution will not happen because validation needs to be performed first. The code cannot proceed/enter unless the condition is satisfied. Unlike do-while, the program will be executed atleast once before validating.
24th Jul 2020, 7:41 AM
Jay Gilbert Garzon
Jay Gilbert Garzon - avatar