Bird
0
0

How can you write an if statement that only runs when a variable score is between 50 and 100 inclusive?

hard📝 Application Q9 of 15
C - onditional Statements
How can you write an if statement that only runs when a variable score is between 50 and 100 inclusive?
Aif (score >= 50 || score <= 100) { /* code */ }
Bif (score >= 50 && score <= 100) { /* code */ }
Cif (score > 50 || score < 100) { /* code */ }
Dif (score > 50 && score < 100) { /* code */ }
Step-by-Step Solution
Solution:
  1. Step 1: Understand range condition

    Score must be at least 50 and at most 100.
  2. Step 2: Use logical AND to combine conditions

    Both conditions must be true, so use && with >= and <=.
  3. Final Answer:

    if (score >= 50 && score <= 100) { /* code */ } -> Option B
  4. Quick Check:

    Use && for both conditions true [OK]
Quick Trick: Use && to combine multiple conditions in if [OK]
Common Mistakes:
  • Using || which allows wrong values
  • Using strict > or < excluding boundaries
  • Confusing logical operators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes