Skip to content
Exercise · Conditions · lesson 6 of 6

Exercise: grade from a score

Write a function char grade(int score) that turns a score into a grade. A score of 90 or more gets 'A', 75–89 gets 'B', 60–74 gets 'C', and below 60 gets 'F'.

  • grade(90) → 'A'
  • grade(74) → 'C'
  • grade(59) → 'F'

Constraints: score is an integer from 0 to 100 inclusive.

grade.cpp — cpp
cpp · 4 lines
Ctrl+Enter run · Esc leave editor