Map a score onto a letter with chained else if tests, highest bar first.
A grade calculator maps a score onto a letter by checking the highest bar first. 95 should be A, not C. The chain is a staircase you walk down until a step fits.
score
no
yes
Each step highlights the matching C line. Program output appears only when a line that prints actually runs.
Five questions. Pick one answer each, then Check answers. The correct choice turns green.
1. Score 85 prints:
>= 75 and not >= 90.
2. Why test 90 before 50?
Order matters.
3. Score 49 prints:
Final else.
4. Score 90 prints:
>= 90.
5. This chain is better as switch when:
Ranges want if; exact days want switch.