Bird
0
0

Given the code below, what will be the output?

hard📝 Application Q15 of 15
C - Operators and Expressions
Given the code below, what will be the output?
int a = 4, b = 4, c = 5;
if (a == b && b < c) {
    printf("Yes\n");
} else {
    printf("No\n");
}

Choose the correct output considering relational operators combined with logical operators.
AYes
BNo
C4
DSyntax Error
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate the first condition a == b

    Both a and b are 4, so a == b is true.
  2. Step 2: Evaluate the second condition b < c

    b is 4 and c is 5, so b < c is true.
  3. Step 3: Combine conditions with logical AND

    Both conditions are true, so the combined condition is true, executing the if block.
  4. Final Answer:

    Yes -> Option A
  5. Quick Check:

    (4 == 4) && (4 < 5) = true [OK]
Quick Trick: Both conditions must be true for && to print Yes [OK]
Common Mistakes:
  • Ignoring logical AND meaning
  • Mixing up == and =
  • Assuming false when both conditions true

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes