Difficulty: Easy
Correct Answer: 6.000000
Explanation:
Introduction / Context:
This tests knowledge of sqrt from math.h and default floating-point formatting in printf. In C, %f prints a double value with six digits after the decimal by default.
Given Data / Assumptions:
Concept / Approach:
Compute sqrt(36.0) then format the result using "%f". No integer formatting or rounding tricks are involved; it is a direct call and a direct print.
Step-by-Step Solution:
Evaluate sqrt(36.0) → 6.0 (double).printf("%f", 6.0) → "6.000000".
Verification / Alternative check:
Changing the format to "%.1f" would print "6.0". Using "%g" would typically print "6".
Why Other Options Are Wrong:
"6.0" or "6": do not match the exact formatting of %f with default precision.Error: math.h is included; no prototype error occurs.
Common Pitfalls:
Confusing %f (fixed six decimals) with %g or custom precisions.
Final Answer:
6.000000
Discussion & Comments