Bird
0
0

Identify the problem in this code:

medium📝 Debug Q7 of 15
C - Operators and Expressions
Identify the problem in this code:
int x = 7;
int y = 2;
int z = x / y;
printf("%f", z);
AIncorrect variable declaration
BDivision operator is incorrect
CUsing %f to print an int variable
DMissing variable initialization
Step-by-Step Solution
Solution:
  1. Step 1: Check variable types and printf format

    Variable z is int but printed with %f (float format).
  2. Step 2: Understand format specifier mismatch

    Using %f for int causes undefined or wrong output.
  3. Final Answer:

    Using %f to print an int variable -> Option C
  4. Quick Check:

    Match printf format with variable type [OK]
Quick Trick: Use %d for int, %f for float in printf [OK]
Common Mistakes:
  • Mismatching format specifiers
  • Assuming division error
  • Ignoring initialization

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes