What are the entry controlled and exit controlled loops?



Depending on the position of the control statement in the loop, a control structure can be classified into two types; entry controlled and exit controlled. They are described below.

Suggested Reading:
  1. 3 Differences between entry and exit controlled loops with examples.
  2. What are the counter controlled and sentinel controlled loops?

Entry controlled loop:

The types of loop where the test condition is stated before the body of the loop, are known as the entry controlled loop. So in the case of an entry controlled loop, the condition is tested before the execution of the loop. If the test condition is true, then the loop gets the execution, otherwise not. For example, the for loop is an entry controlled loop. In the given figure, the structure of an entry controlled loop is shown.


ContentMiddleAd

Exit controlled loop:

The types of loop where the test condition is stated at the end of the body of the loop, are know as the exit controlled loops. So, in the case of the exit controlled loops, the body of the loop gets execution without testing the given condition for the first time. Then the condition is tested. If it comes true, then the loop gets another execution and continues till the result of the test condition is not false. For example, the do statement or the do....while loop is an exit controlled loop. The structure of an exit controlled loop is given in the given figure.

Suggested Reading:
  1. 3 Differences between entry and exit controlled loops with examples.
  2. What are the counter controlled and sentinel controlled loops?

JOIN THE COMMUNITY

Like & Share with people you care

No SPAM, only email notification if new posts were published.

Recommended Recommends

Comments

Contact Us