Difficulty: Easy
Correct Answer: 4.320000e+01, 43.200001, 43.2
Explanation:
Introduction / Context:
The format specifiers %e, %f, and %g print floating-point values differently. Understanding each specifier and the effect of binary rounding explains the exact output.
Given Data / Assumptions:
Concept / Approach:
Compute how each format represents 43.20. Due to binary rounding, the closest representable float near 43.20 may be slightly larger than 43.2, leading to 43.200001 with %f.
Step-by-Step Solution:
%e → "4.320000e+01".%f → prints six decimals → "43.200001" on many systems because 43.20 is not exactly representable in binary.%g → compact form → "43.2".
Verification / Alternative check:
Printing with higher precision (e.g., "%.9f") will reveal the tiny rounding difference more clearly.
Why Other Options Are Wrong:
They contain impossible suffixes (like "f" in output) or arbitrary rounding that does not match default printf behavior.
Common Pitfalls:
Expecting %f to always show exactly the decimal literal; forgetting argument promotion of float to double in variadic functions.
Final Answer:
4.320000e+01, 43.200001, 43.2
Discussion & Comments