Difficulty: Easy
Correct Answer: printf("%f %lf", a, b);
Explanation:
Introduction / Context:Unlike scanf, printf receives its floating arguments after default promotions, so both float and double are passed as double. Still, choosing correct format specifiers avoids undefined behavior and documents intent clearly when printing mixed floating types.
Given Data / Assumptions:
Concept / Approach:
Step-by-Step Solution:
Choose %f for the first value (a), which is promoted to double.Choose %lf (or %f) for the second value (b), which is a double.Therefore, printf("%f %lf", a, b); correctly prints both values.Verification / Alternative check:
Testing with typical compilers shows identical output for %f and %lf in printf, while %Lf requires a long double argument.Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
printf("%f %lf", a, b);
Discussion & Comments