Skip to the task
Layout
Back to classic view

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

EDITTask 6 of 21 · step 4: An algorithm as a sequence of statementsPrint the algorithm step by step
Print the algorithm step by step in practice/01/

After "Hello, world!" add an empty line and the steps of the average algorithm, each in its own printf.

Checklist

  • Every task is one commit with a clear message.
Details & hint

A C program is a sequence: statements run one after another, top to bottom. printf("\n"); prints only a new line, so an empty line appears in the output.

Try it: swap two printf lines and run. The steps are printed in the order they are written. Then put them back.

practice 01 main.c Code Diff +6
M · MODIFIED git diff: red = old code, green = new.
--- a/practice/01/main.c
+++ b/practice/01/main.c
@@ -2,5 +2,11 @@
int main(void) {
printf("Hello, world!\n");
+ printf("\n");
+ printf("Algorithm: the average of grades\n");
+ printf("1. Add up all the grades.\n");
+ printf("2. Count how many grades there are.\n");
+ printf("3. Divide the sum by the count.\n");
+ printf("4. Print the answer.\n");
return 0;
}