basics · beginner · ~15 min
Map ranges to discrete outputs.
Convert a numeric score into a letter grade by checking ordered thresholds.
Implement char grade_letter(int score) that maps a score to a letter: 'A' for score >= 90, 'B' for >= 80, 'C' for >= 70, 'D' for >= 60, and 'F' otherwise. Check the highest threshold first so each band wins correctly. No main — the grader calls it.
A single int score (typically 0-100).
Returns the grade letter: one of 'A', 'B', 'C', 'D', 'F'.
grade_letter(95) -> 'A'
grade_letter(82) -> 'B'
grade_letter(71) -> 'C'
grade_letter(60) -> 'D'
grade_letter(40) -> 'F'
'D'; below 60 is 'F'.A single int score (typically 0-100).
The grade letter: 'A', 'B', 'C', 'D', or 'F'.
Thresholds: >=90 A, >=80 B, >=70 C, >=60 D, else F.
char grade_letter(int score) {
/* TODO */
return 'F';
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.