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:

  • 90 or more: 'A';
  • 75–89: 'B';
  • 60–74: 'C';
  • below 60: 'F'.

Examples:

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

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

Do not add extra #include lines unless the task says so explicitly.

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

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way