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?

Counter controlled loop
Sentinel controlled loop
Number of execution
Previously known number of execution occurs.
Unknown number of execution occurs.
Condition variable
Condition variable is known as counter variable.
Condition variable is known as sentinel variable.
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.
= = = = = = = =
sum = 0;
n = 1;
while (n <= 10)
sum = sum + n*n;
n = n+ 1;
= = = = = = = =
= = = = = =
printf(“Input a number.\n”);
scanf("%d", &num);
= = = = = =

Author: Tanmay Chakrabarty

Tanmay Chakrabarty is a former CSE student, currently working as a Senior Software Engineer with 5+ years of experience in the field of Web Application development in PHP+MySQL platform with strong skills in Javascript, JQuery, JQuery UI and CSS. He tries to write notes every week but fails due to heavy loads of duty.

Recommended Recommends


Contact Us