Skip to the task
Layout
Back to classic view

You are looking ahead. Your place is still task 1: Functions.

RUNTask 5 of 23 · step 3: Grades with functionsRun it with 3, 9, 11, 4, 10
Run it with 3, 9, 11, 4, 10 in practice/05/

File → Reload CMake Project, pick p05_grades and ▶. Type 3, then 9, 11, 4, 10.

Checklist

  • Every task is one commit with a clear message.
  • Zero compiler warnings: the code builds with -Werror.
  • Once per topic you step through your code in the debugger (CLion, gdb).
  • Every function has preconditions and postconditions, and assert tests check them.
Details & hint
$ .\build\debug\practice\05\p05_grades.exe
How many grades? 3
1. Grade: 9
Very good
2. Grade: 11
Grade must be between 1 and 10.
Grade: 4
Unsatisfactory
3. Grade: 10
Excellent
Average: 7.67

You should see: Exactly as in topic 3: 11 is rejected, the average is 7.67. The behaviour didn't change: that is refactoring.

practice 05 CMakeLists.txt Code Diff +2
A · NEW FILE Create this file. Every line is new: see the green bar.
add_executable(p05_grades main.c)
target_link_libraries(p05_grades PRIVATE course_input)
opened for this task
$ .\build\debug\practice\05\p05_grades.exe
How many grades? 3
1. Grade: 9
Very good
2. Grade: 11
Grade must be between 1 and 10.
Grade: 4
Unsatisfactory
3. Grade: 10
Excellent
Average: 7.67