A sentinel value:
-
is used to prevent infinite loops.
-
must be a negative value.
-
signals the end of a list of data.
-
Both a and b.
-
All of the above.
A sentinel value is a special value chosen to indicate the end of a data stream - it's not part of the actual data, just a signal. For example, using -999 or 999 to mark that there are no more valid test scores to process. It can be any value outside the normal data range, not necessarily negative.
To answer this question, you need to understand the concept of a sentinel value.
A sentinel value is a special value that is used to indicate the end of a sequence or list of data. It is used to signal that there is no more data to be processed.
Option A) A sentinel value is not specifically used to prevent infinite loops. It is used to indicate the end of data, but it does not directly prevent infinite loops.
Option B) A sentinel value does not have to be a negative value. It can be any value that is chosen to represent the end of the data.
Option C) This option is correct. A sentinel value signals the end of a list of data.
Option D) Option D is incorrect because a sentinel value does not have to be a negative value. Therefore, both a and b are not always true.
Option E) Option E is incorrect because not all of the above options are correct. Only option C is correct.
The correct answer is C. This option is correct because a sentinel value is used to signal the end of a list of data.