Bird
0
0

What is the output of this C code?

medium📝 Predict Output Q4 of 15
C - Operators and Expressions
What is the output of this C code?
int x = 10, y = 3;
printf("%d", x % y);
A3
B1
C0
D7
Step-by-Step Solution
Solution:
  1. Step 1: Understand the modulus operator %

    The % operator gives the remainder of division of x by y.
  2. Step 2: Calculate 10 % 3

    10 divided by 3 is 3 with remainder 1, so 10 % 3 = 1.
  3. Final Answer:

    1 -> Option B
  4. Quick Check:

    Modulus 10 % 3 = 1 [OK]
Quick Trick: Modulus % gives remainder after division [OK]
Common Mistakes:
  • Confusing % with division
  • Expecting quotient instead of remainder
  • Miscalculating remainder

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes