Lesson 3 / 36
Hello, World!
Your first program, line by line.
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
- Moves output to a new line
- Ends the program
Answer
Moves output to a new line — `\n` is the newline escape sequence.