5. Entry controlled
Test condition appears at the
beginning.
Control variable is counter
variable.
Each execution occurs by
testing condition.
Eg:
sum = 0;
n = 1;
while (n <= 10)
{
sum = sum + n*n;
n = n+ 1;
}
Exit controlled
Test condition appears at the end.
Control variable is counter &
sentinel variable.
Each execution except the first
one occurs by testing condition.
Eg:
do
{
printf(“Input a number.n”);
scanf("%d", &num);
}
while(num>0);
12. do…while STATEMENT
Do while has a loop condition only that is tested
after each iteration to decide whether to continue
with next iteration or terminate the loop.