Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q5 of 15
C - Operators and Expressions
What will be the output of this code?
int x = 10, y = 5;
int z = x / y * 2 + 3;
printf("%d", z);
A7.0
B5
C8
D7
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate division and multiplication first

    x / y = 10 / 5 = 2, then 2 * 2 = 4.
  2. Step 2: Add 3 to the result

    4 + 3 = 7.
  3. Final Answer:

    7 is printed -> Option D
  4. Quick Check:

    Division and multiplication before addition = 7 [OK]
Quick Trick: Division and multiplication before addition [OK]
Common Mistakes:
  • Assuming integer division gives float
  • Adding before multiplication
  • Confusing output with float

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes