A sentinel value:

  1. is used to prevent infinite loops.

  2. must be a negative value.

  3. signals the end of a list of data.

  4. Both a and b.

  5. All of the above.


Correct Option: C

AI Explanation

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.

Find more quizzes: