Bird
0
0

Identify the mistake in this code:

medium📝 Debug Q7 of 15
C - Input and Output
Identify the mistake in this code:
float temperature = 36.5;
printf("Temperature: %d", temperature);
AUsing %d to print a float variable is incorrect.
BVariable <code>temperature</code> should be declared as int.
CMissing newline character in printf string.
DThe variable <code>temperature</code> is not initialized.
Step-by-Step Solution
Solution:
  1. Step 1: Check variable type

    temperature is a float.
  2. Step 2: Check format specifier

    %d is for integers, not floats.
  3. Final Answer:

    Using %d to print a float variable is incorrect. -> Option A
  4. Quick Check:

    Use %f for float variables [OK]
Quick Trick: Use %f for floats, not %d [OK]
Common Mistakes:
  • Using %d for float variables
  • Not matching format specifier with variable type
  • Ignoring type mismatch warnings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes