Question 6
Back to Exercise
Which pair is correct?
- A printf %lf for double only; scanf %f for both
- B %f is always wrong for double
- C printf %f works for float and double; scanf needs %f for float and %lf for double Correct
- D Both functions treat %f and %lf the same
Correct Answer: Option C
Variadic arguments promote float to double, so printf only ever receives doubles and %f serves both (%lf is also accepted). scanf receives pointers, and a double * must be read with %lf.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!