Bird
0
0

Which of the following expressions correctly checks if variable x is NOT between 5 and 15 (inclusive) in C?

hard📝 Application Q9 of 15
C - Operators and Expressions
Which of the following expressions correctly checks if variable x is NOT between 5 and 15 (inclusive) in C?
A(x <= 5 && x >= 15)
B(x < 5 || x > 15)
C(x > 5 || x < 15)
D(x < 5 && x > 15)
Step-by-Step Solution
Solution:
  1. Step 1: Understand the NOT between condition

    To check if x is outside 5 to 15, x must be less than 5 OR greater than 15.
  2. Step 2: Use logical OR with relational operators

    Use '||' to combine 'x < 5' and 'x > 15' for the correct condition.
  3. Final Answer:

    (x < 5 || x > 15) -> Option B
  4. Quick Check:

    Use '||' to check outside range [OK]
Quick Trick: Use '||' to check if outside a range [OK]
Common Mistakes:
  • Using '&&' instead of '||'
  • Using incorrect inequality signs
  • Confusing inclusive and exclusive bounds

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes