You are looking at lesson 6. Your place is still lesson 5, task 1: Functions.
hw/06-gradebook: grades in an array, the average, the highest and lowest, a sorted copy, the distribution and a search.
Checklist
From this topic on, the homework grows one program: the gradebook. Each topic adds its part: 7 modules, 9 names and safe input, 10 structures, 11 a file, 12 a dynamic array. The first version goes in the folder hw/06-gradebook.
hw/06-gradebook/main.cThe program asks how many grades there are (1 to 30), reads them into an array (each from 1 to 10) and prints:
How many grades? 5
1. Grade: 8
2. Grade: 10
3. Grade: 7
4. Grade: 9
5. Grade: 10
Grades: 8 10 7 9 10
Average: 8.80
Highest: 10
Lowest: 7
Sorted: 7 8 9 10 10
Distribution:
7: *
8: *
9: *
10: **
Grade to find (0 to stop): 9
9 is at position 4.
Grade to find (0 to stop): 6
6 not found.
Grade to find (0 to stop): 0
Number of grades must be between 1 and 30. and Grade must be between 1 and 10. The array's size is MAX_GRADES, already defined.times[11], where times[g] is how many times grade g occurred. The grade is right-aligned: %2d.Each part is its own function with a contract and an assert, as in the topic: read_grades, print_grades, average, highest, lowest, sort_grades, find_grade, print_distribution. Their parameters are int grades[] and int count (and int value for the search). main only calls them.
Three output tests (hw/06-gradebook/tests/) and a file test: main.c has an assert( and no TODO left.
ctest --preset debug -L hw06
The most common mistake is a space at the end of the line, when each grade is printed with "%d ":
=== hw06_gradebook_1: FAILED ===
The output differs on line 7.
expected: |Grades: 8 10 7 9 10|
got: |Grades: 8 10 7 9 10~|
(\t = tab, ~ = a space at the end of the line)
The ~ is that space. Write the space before each value except the first, like the topic's print_array.
Commit and push. Actions → Points: HW 6 (Gradebook), 10 points when all four tests pass.
In topic 7 you move this code to hw/07-gradebook and split it into modules, so write it tidily already now.
Each one ticks itself when you do it.
All six done. You know your way around.
It is laid out like CLion: the same panels in the same places. This tour shows each one, and you can reopen it any time with Tour.
Switches the left panel: Lesson plan, Project files, Changes. Click the active icon again to hide the panel.
In CLion: the tool window bar runs down the left edge, too.
This part is not on this task: it appears when a task needs it.
Every task in this lesson. Now marks your place. Clicking a task only lets you look; it never moves your place. Project files and Changes open here too.
In CLion: this spot holds the Project view (the file tree).
This part is not on this task: it appears when a task needs it.
Opens the file for your task by itself. A tab appears for each file the step opens. The breadcrumbs above the code show the folder.
In CLion: the same editor tabs and breadcrumbs.
This part is not on this task: it appears when a task needs it.
Diff shows what changed, like git diff: red is the old code, green the new.
In CLion: the diff view in the Commit window looks the same.
This part is not on this task: it appears when a task needs it.
Terminal for build commands, Database to see your tables. They open by themselves when a task needs them. Drag the top edge to resize.
In CLion: Terminal, and the Database tool window.
This part is not on this task: it appears when a task needs it.
What to do now, right above the code, so you never miss it. Numbered notes in the code explain the important lines. Details shows what you should see and a hint.
In CLion: no equivalent: this is your lecturer's guide.
This part is not on this task: it appears when a task needs it.
Done is the only button that moves you forward. Look back lets you review without losing your place.
This part is not on this task: it appears when a task needs it.
Guided, Focus code or Floating. You can drag the panel edges too. Your layout is remembered for next time.
In CLion: you can also rearrange and hide tool windows.
This part is not on this task: it appears when a task needs it.
Six small missions. Each one ticks itself when you do it, so you know you have found everything.