Difficulty: Easy
Correct Answer: 10.100000
Explanation:
Introduction / Context:
This question focuses on unions in C and accessing the same member that was most recently written. It checks whether learners understand that reading back the same active member yields the stored value, subject to normal floating-point formatting in printf.
Given Data / Assumptions:
Concept / Approach:
If you write to one member of a union and then read the same member, you get the stored value. Using a different member without writing it is not meaningful. printf("%f") will display the value with default precision (typically 6 places after the decimal), so 10.10f prints as 10.100000 by default.
Step-by-Step Solution:
Verification / Alternative check:
Formatting can be changed using "%.2f" to print "10.10". With the default "%f", expect "10.100000".
Why Other Options Are Wrong:
Common Pitfalls:
Assuming unions always cause aliasing issues; here the same member is consistently used, which is fine.
Final Answer:
10.100000
Discussion & Comments