Difficulty: Easy
Correct Answer: 0, 0.000000
Explanation:
Introduction / Context:
Structures in C can be partially initialized with aggregate initializers. Understanding what happens to unspecified members avoids undefined behavior and misinterpretation of output.
Given Data / Assumptions:
Concept / Approach:
In an aggregate initializer, any members not explicitly initialized are initialized as if by zero. This rule applies regardless of storage duration when an initializer is present. Therefore, age becomes 0 and sal becomes 0.0.
Step-by-Step Solution:
Assign name = "Tiger".Omitted members age and sal → set to 0 and 0.0 respectively.Print “0, 0.000000”.
Verification / Alternative check:
Explicitly writing struct emp e = {"Tiger", 0, 0.0f}; yields identical behavior; both are well-defined.
Why Other Options Are Wrong:
B: Not garbage—there is an initializer. C: No syntax error. D/E: The behavior is specified by the C standard and is not implementation dependent in this context.
Common Pitfalls:
Confusing uninitialized automatic structs (indeterminate) with partially initialized ones (rest zero). Forgetting the difference between designated and positional initializers.
Final Answer:
0, 0.000000
Discussion & Comments