Bird
0
0

What will be the output of the following code?

medium📝 Predict Output Q13 of 15
C - Input and Output
What will be the output of the following code?
int x = 10;
float y = 5.5;
printf("%d %f", x, y);
A10 5.5
B10 5.500000
C5.5 10
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand format specifiers in printf

    %d prints integer as is, %f prints float with 6 decimal places by default.
  2. Step 2: Match variables to specifiers

    x is 10 (int), printed by %d. y is 5.5 (float), printed by %f as 5.500000.
  3. Final Answer:

    10 5.500000 -> Option B
  4. Quick Check:

    Integer and float print with %d and %f [OK]
Quick Trick: Floats print with 6 decimals by default using %f [OK]
Common Mistakes:
  • Expecting %f to print fewer decimals
  • Swapping variable order
  • Using %d for float causing wrong output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes