C Syntax & Program Structure
A C source file follows the same skeleton every time: #include lines for libraries, then function definitions — with exactly one main(). Statements end in semicolons, blocks wrap in curly braces, and whitespace (including newlines) means nothing to the compiler.
Comments are // for line comments and /* ... */ for blocks. Naming convention is overwhelmingly snake_case for variables and functions, PascalCase or UPPER for types and macros — matching the standard library's own style (printf, size_t, NULL).
Preprocessor lines first
#include <stdio.h> is handled before compilation, pasting library declarations into your file.
Functions hold all code
Every executable statement lives inside some function; the program starts at main() and nothing runs at file scope.
Semicolons end statements
Every declaration and statement ends with a semicolon — the missing semicolon is the most common beginner error.
Braces define blocks
Function bodies, loop bodies, and if-branches wrap in { }; indentation is for humans only.
#include <stdio.h> // Program entry pointint main(void) { printf("v1\n"); /* print version */ return 0;}Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in C yourself — building beats watching.