3 Differences between counter and sentinel controlled loops. Counter controlled loop VS Sentinel controlled loop



The differences between the counter and sentinel controlled loops are as follows.

Read More: What are the counter controlled and sentinel controlled loops?

No.
Topics
Counter controlled loop
Sentinel controlled loop
01
Number of execution
Previously known number of execution occurs.
Unknown number of execution occurs.
02
Condition variable
Condition variable is known as counter variable.
Condition variable is known as sentinel variable.
03
Value and limitation of variable
The value of the variable and the limitation of the condition for the variable both are strict.
The limitation for the condition variable is strict but the value of the variable varies in this case.
04
Examples
= = = = = = = =
sum = 0;
n = 1;
while (n <= 10)
{
sum = sum + n*n;
n = n+ 1;
}
= = = = = = = =
= = = = = =
do
{
printf(“Input a number.\n”);
scanf("%d", &num);
}
while(num>0);
= = = = = =




Recommended Recommends

Comments

Contact Us