An entry control loop checks the condition at the time of entry and if condition or expression becomes true then control transfers into the body of the loop, for loop and while loop are the examples of Entry Controlled Loop. A while loop is a control flow statement that allows the loop statements to be executed as long as the condition is true.
Type:
Entry control loop
Syntax:
Control flow:
Step 1 : Test – expression is evaluated to either True or False;
Step 2 : If test – expression is true;
(a) The body of the loop is executed.
(b) Control is transferred to step 1.
Step 3: If test – expression is false, the control exits the while loop.
Example:
int a = 1;
while (a<=10)
{
cout << a << ‘\t+’;
a+=2;
}
Output:
1 3 5 7 9