You are looking at lesson 1. Your place is still lesson 4, task 1: Style.
Algorithms, pseudocode, the three blocks (sequence, selection, repetition) and flowcharts.
In this topic you write an algorithm as pseudocode and as a flowchart, then write your first C program. What to install, the course plan with its hours and how you are assessed are on the course start page.
A computer does not understand "roughly". An algorithm is a finite, unambiguous sequence of steps that turns input data into a result.
Before writing code, it helps to write the algorithm as pseudocode: short sentences, without the rules of any programming language. Over the course you build a gradebook program, so the first example is the average of grades:
1. sum ← 0, count ← 0
2. While there are grades left:
2.1. sum ← sum + grade
2.2. count ← count + 1
3. If count > 0:
3.1. Print sum / count.
Otherwise:
3.2. Print "No grades".
The arrow ← means "remember": sum ← sum + grade – add the grade to the sum and remember the new sum.
Any algorithm can be built from just three blocks:
That is structured programming: a program built from these three blocks, nested inside each other, with no jumping to arbitrary places.
The same algorithm can be drawn as a flowchart. Every shape has its own meaning:
| Shape | Meaning |
|---|---|
| oval | start or end |
| rectangle | an action, e.g. sum ← 0 |
| diamond | a condition with two exits: yes and no |
| parallelogram | input or output |
In the homework you write the flowchart as text, in the Mermaid language, and GitHub draws it for you. The average algorithm in Mermaid looks like this:
flowchart TD
start([Start]) --> init[sum = 0, count = 0]
init --> more{Grades left?}
more -- yes --> add[sum = sum + grade<br>count = count + 1]
add --> more
more -- no --> any{count > 0?}
any -- yes --> avg[/Print the average/]
any -- no --> none[/Print: no grades/]
avg --> stop([End])
none --> stop
([...]) is an oval, [...] a rectangle, {...} a diamond, [/.../] a parallelogram, and --> an arrow.
This topic's C programs are only a sequence: statements run one after another, top to bottom. You write selection and repetition in C in topic 3, but you write them as pseudocode and a flowchart 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.