SkillByAIOpen interactive version →

Lesson 3 / 38

Hello, World!

Write, compile and run your first C program and understand each line of Hello, World.

The program

Save this as hello.c.

#include <stdio.h>

int main(void) {
    printf("Hello, World!\n");
    return 0;
}

Output:

Hello, World!

What each line does

#include <stdio.h> loads the I/O library · int main(void) is where execution starts · printf writes text, \n is a newline · return 0 reports success to the OS.

Quick check: What does `\n` do in `printf`?

  • Prints a backslash and n
  • Ends the program
  • Moves output to a new line
  • Ends the program
Answer

Moves output to a new line — `\n` is the newline escape sequence.