Your First Program
6 min · C
Write and run your very first C program, right here on the page.
Enemy 1 of 5
How a C program is put together
Almost every language you'll ever learn traces its habits back to C, so this first lesson is worth taking slowly. A C program always begins execution in a function called main — no matter how large a real C program is, when you run it, the operating system looks for main and starts there.
The line #include <stdio.h> at the top brings in the "standard input/output" library. Without it, functions like printf simply wouldn't exist for you to call — C itself is a very small language, and almost everything useful comes from libraries you explicitly include.
C compiles your whole file down to machine instructions before it ever runs (unlike an interpreted language such as Python), which is part of why C programs tend to run fast, but also why a typo can produce a compiler error rather than the program politely telling you about the problem while running.
Loading editor...