Bird
0
0

Identify the mistake in this code:

medium📝 Debug Q7 of 15
C - onditional Statements
Identify the mistake in this code:
int score = 85;
if (score >= 90)
    printf("A grade\n");
else
    printf("B grade\n");
else
    printf("C grade\n");
AIncorrect variable type
BMissing semicolon after printf
CNo mistake
DMultiple else statements without if
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the if-else structure

    There are two else statements but only one if. C does not allow multiple else without else if.
  2. Step 2: Confirm other syntax

    Semicolons and variable type are correct. The problem is the extra else.
  3. Final Answer:

    Multiple else statements without if -> Option D
  4. Quick Check:

    Only one else per if allowed [OK]
Quick Trick: Use else if for multiple conditions [OK]
Common Mistakes:
  • Using multiple else without else if
  • Missing semicolons (not here though)
  • Confusing else with else if

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes