LOOPING STRUCTURES
LOOPS
Entry Controlled
Loop
Exit Controlled
Loop
ENTRY CONTROLLED
LOOPS
EXIT CONTROLLED
LOOPS
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);
ENTRYCONTROLLED
LOOPS
for Statement
while
Statement
for STATEMENT
for STATEMENT
while STATEMENT
while STATEMENT
EXITCONTROLLED
LOOPS
do….while
Statement
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.
EXAMPLES(quicktime player reqd)
Looping Structures

Looping Structures