What is an entry control loop? Explain any one of the entry-controlled loops with a suitable example.
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;
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.
using namespace std;
int main ()
cout<<“The sum of 1 to 10 is “<<sum; return 0;
The sum of 1 to 10 is 55