Difficulty: Easy
Correct Answer: -1, 0, 6, 7, 8, 9
Explanation:
Introduction / Context: This item assesses understanding of how C assigns values to enum constants when some are explicitly set and others are left to auto-increment from the previous value.
Given Data / Assumptions:
Concept / Approach: The rule: an unassigned enumerator takes the previous enumerator’s value plus one. When a new explicit value appears (like WED = 6), auto-increment resumes from that value. Therefore THU = 7, FRI = 8, SAT = 9.
Step-by-Step Solution:
MON = -1 (explicit).TUE = -1 + 1 = 0 (implicit).WED = 6 (explicit).THU = 6 + 1 = 7 (implicit).FRI = 8 (implicit); SAT = 9 (implicit).Verification / Alternative check: Printing the constants directly, as in the code, confirms the computed sequence without needing variables or sizeof concerns.
Why Other Options Are Wrong:
Common Pitfalls: Assuming auto-increment continues from the earliest explicit value rather than the most recent explicit assignment. Each explicit assignment resets the running value for subsequent implicit ones.
Final Answer: -1, 0, 6, 7, 8, 9
Discussion & Comments