You are looking at lesson 3. Your place is still lesson 10, task 1: struct.
hw/03/main.c: read the students' points, turn them into grades with stars, and print how many passed and the best result.
Checklist
The folder hw/03 has a main.c stub and two tests.
hw/03/main.cPrint the text exactly as below, because that is what the tests check.
How many students? . While the answer is less than 1: At least one student is needed. and ask again.1. ) and ask Points: . While the points are not 0–100: Points must be between 0 and 100. and ask again (without the number now).Grade: , the grade, a space and as many stars * as the grade.| Points | 95–100 | 85–94 | 75–84 | 65–74 | 55–64 | 45–54 | 35–44 | 25–34 | 15–24 | 0–14 |
|---|---|---|---|---|---|---|---|---|---|---|
| Grade | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
An example (hw/03/tests/1.in.txt):
How many students? 4
1. Points: 87
Grade: 9 *********
2. Points: 120
Points must be between 0 and 100.
Points: 97
Grade: 10 **********
3. Points: 44
Grade: 4 ****
4. Points: 63
Grade: 6 ******
Passed: 3 of 4 (75.0 %)
Best result: 97 points
for runs as many times as the grade.if / else if chain. There is a shorter way with / too: notice that the limits come every 10.% in a printf string is written %%.The second test (2.in.txt) checks what the example doesn't: 0 students, negative points and the limits 0 and 100.
ctest --preset debug -L hw03
Commit and push. Actions → Points: HW 3 (Exam results), 10 points when both tests pass.
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.