In programming, sentinel value is a special value that is used to terminate a loop. The sentinel value typically is chosen so as to not be a legitimate data value that the loop will encounter and attempt to perform with. ... Also referred to as a flag value or a signal value.
What is the purpose of sentinel value?
The sentinel value is a form of in-band data that makes it possible to detect the end of the data when no out-of-band data (such as an explicit size indication) is provided.
Does a sentinel value have to be?
A sentinel value should be a value that is never going to appear in data. Adding zero to a sum does not change the sum, so the program to add numbers could use zero as a sentinel value. If the list of numbers the user were adding had a zero in it, the user could just skip it without changing the sum.