Tamil Nadu Board of Secondary EducationHSC Science Class 11th

# What is an entry control loop? Explain any one of the entry controlled loops with a suitable example. - Computer Science

What is an entry control loop? Explain any one of the entry-controlled loops with a suitable example.

#### Solution

In an entry-controlled loop, the test- expression is evaluated before entering into a loop, while and for statements are called as entry controlled loop.

Working of while loop:

A while loop is a control flow statement that allows the loop statements to be executed as long as the condition is true. The while loop ¡s an entry-controlled loop because the test-expression is evaluated before entering into a loop.

The while loop syntax is:

while (Test expression )
{
Body of the loop;
}
Statement-x;
In a while loop, the test expression is evaluated and if the test expression result is true, then the body of the loop is executed and again the control is transferred to the while loop. When the test expression result is false then control is transferred to statement-x.

The control flow and flow chart of the while loop is shown below.

Example:

#include <iostream>
using namespace std;
int main ()
{
int i=1,sum=0;
while(i<=10)
{
sum=sum+i;
i++;
}
cout<<“The sum of 1 to 10 is “<<sum; return 0;
}
Output
The sum of 1 to 10 is 55

Concept: Control Statements
Is there an error in this question or solution?