What is an entry control loop? Explain any one of the entry controlled loop with suitable example.
Answers
Answer:
an entry controlled loop, a condition is checked before executing the body of a loop. It is also called as a pre-checking loop. In an exit controlled loop, a condition is checked after executing the body of a loop. It is also called as a post-checking loop. Test condition is checked first, and then loop body will be executed. Loop body will be executed first, and then condition is checked. If Test condition is false, loop body will not be executed for loop and while loop are the examples of Entry Controlled Loop.
Answer:
What is an entry control loop? Explain any one of the entry controlled loop with suitable example.
Explanation:
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
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