Sometimes, loop control may need to be based on the value of what we are processing. In this case, we would sentinel-controlled repetition. Sentinel-controlled repetition is sometimes called indefinite repetition because it is not known in advance how many times the loop will be executed. It is a repetition procedure for solving a problem by using a sentinel value (also called a signal value, a dummy value or a flag value) to indicate "end of data entry". The sentinel value itself is not a part of the processed data.
An example of when we would use sentinel-controlled repetition is when we are processing data from a file and we do not know in advance when we would reach the end of the file.
|Fook Yuen Sin - Team 1|