C/C++ Arena

Hello World in C

Write, compile and run your first C program, and learn what each line of Hello World does.

Every C program starts running at main. The smallest useful program prints a line of text with printf:

To build it on your own machine, save it as hello.c and run gcc -Wall hello.c -o hello, then ./hello. The -Wall flag turns on warnings, which catch many mistakes early.

Example

#include <stdio.h>

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

Output:

Hello, World!

Practice it