5 questions to test your understanding
A programmer writes the following grading logic: `if (score >= 60) { grade = 'D' } else if (score >= 70) { grade = 'C' } else if (score >= 80) { grade = 'B' } else if (score >= 90) { grade = 'A' }`. A student scores 93. What grade do they receive?
When should you choose an else-if chain over multiple independent if statements?
In an else-if chain, most conditions are evaluated most of the time the chain runs, regardless of which condition is true.
The order in which conditions appear in an else-if chain has no effect on program correctness, as long as the conditions cover most cases.
Explain why an else-if chain with poorly ordered conditions can silently produce wrong output instead of an error, and how you would detect or prevent this bug.