Difficulty: Easy
Correct Answer: 0 2 1
Explanation:
Introduction / Context: This checks understanding of default numbering of enum constants in C and how assigning them to variables results in specific integer outputs with printf.
Given Data / Assumptions:
Concept / Approach: With no explicit assignments, pass = 0, fail = 1, absent = 2. The program prints the underlying integer values of the enumerators assigned to stud1, stud2, and stud3.
Step-by-Step Solution:
Derive values: pass = 0; fail = 1; absent = 2.Substitute: stud1 = 0, stud2 = 2, stud3 = 1.printf prints: 0 2 1.Verification / Alternative check: Adding explicit values (e.g., pass = 10) would shift subsequent values. With defaults, the simple 0/1/2 sequence applies.
Why Other Options Are Wrong:
Common Pitfalls: Mixing up the order of printing with the declaration order, or assuming enums start at 1 by default.
Final Answer: 0 2 1
Discussion & Comments