Example 1 — Trace a grading chain
Show the steps and the answer
score = 85: 85 >= 90 is false; 85 >= 80 is true, so grade = 'B'.
The chain runs the first branch whose condition is true.
Skip the remaining tests for 85.
Once a branch has run, the rest of an else-if chain is not checked, even though 85 >= 70 is also true.
score = 62: 62 >= 90, 62 >= 80, and 62 >= 70 are all false, so the else branch runs: grade = 'F'.
else catches every value that failed all the tests above it.
Answer: 85 gives B; 62 gives F.
Takeaway: In an else-if chain, check the tests from the top and stop at the first true one.