explain what a Sentinel control value is. What control structure uses it? In what context do you think Sentinel Control value is commonly use?
Sentinel:
A sentinel is a value that is used for the loop control and
determines whether the body of the loop must be executed or
not.
The sentinels are used by the loop control structures.
In general the sentinel values are used when the number of times
the loop must be executed is not known in prior.
During the execution process of the loop, the sentinel value can be
used to determine if the loop must still be executed.
Consider an example of a program that reads the positive numbers
from the user.
In such a case, when the number of numbers to be read is not
known.
So when the input is negative, the reading of numbers must be
stopped.
Here, the sentinel can be used and when the input is negative, the
loop that is used to read numbers from the user can be
terminated.
Get Answers For Free
Most questions answered within 1 hours.