Bird
0
0

What output does this C program produce?

medium📝 Predict Output Q5 of 15
C - onditional Statements
What output does this C program produce?
int num = 4;
if (num % 2 != 0) {
    printf("Odd\n");
} else {
    printf("Even\n");
}
AOdd
BEven
CError
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Check the condition

    num % 2 != 0 checks if num is odd. 4 % 2 = 0, so condition is false.
  2. Step 2: Identify executed block

    Since condition is false, the else block runs, printing "Even".
  3. Final Answer:

    Even -> Option B
  4. Quick Check:

    4 is even, so else block runs [OK]
Quick Trick: Odd check false means even output [OK]
Common Mistakes:
  • Misunderstanding modulus operator
  • Swapping outputs for odd/even
  • Ignoring else block

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes