Skip to the task
Layout
Back to classic view

You are looking at lesson 1. Your place is still lesson 8, task 1: Memory.

CREATETask 4 of 21 · step 3: Your first programCreate practice/01/main.c
Create practice/01/main.c in practice/01/

Your first program: it prints one line and ends successfully. Type it by hand, don't copy it.

Checklist

  • Every task is one commit with a clear message.

Numbered notes in the code explain the important lines.

Details & hint
  • #include <stdio.h> brings in the standard input/output library, where printf is declared.
  • int main(void) is the function every C program starts from. void: it takes nothing; int: it returns a whole number.
  • { and } wrap the function body: the statements that run one after another.
  • printf("Hello, world!\n"); prints text. \n is a new line. Every statement ends with ;.
  • return 0; means the program finished successfully: 0 means "all good".

Stuck? The quotes must be straight ", not curly ones. You get curly quotes when you copy text from Word or an email.

practice 01 main.c Code Diff +6
A · NEW FILE Create this file. Every line is new: see the green bar.
#include <stdio.h>
Note 1: Brings in stdio.h, where printf is declared.
int main(void) {
Note 2: The program starts here. Takes nothing, returns an int.
printf("Hello, world!\n");
Note 3: Prints text. \n is a new line, ; at the end.
return 0;
Note 4: 0: the program finished successfully (exit code 0).
}