C example programs
Ten standalone, compilable .c files โ each with its own main() and comments throughout in English. Download them, compile with gcc, and run them yourself.
- 01Basics & I/O
01_basics_and_io.cVariables, built-in types, sizeof, and reading/writing with printf and scanf.
- 02Operators & Control Flow
02_operators_and_control_flow.cArithmetic and logical operators, precedence, if/switch, and the ternary operator.
- 03Loops
03_loops.cwhile, do-while, for, break/continue โ with a prime checker, Fibonacci, and digit sum.
- 04Functions
04_functions.cPrototypes, pass-by-value, and recursion (factorial, GCD, Fibonacci).
- 05Arrays
05_arrays.c1D/2D arrays, linear and binary search, and bubble sort.
- 06Strings
06_strings.cHand-written strlen/strcpy, <string.h>, palindrome check, and case conversion.
- 07Pointers
07_pointers.cAddress-of/dereference, swapping through pointers, pointer arithmetic, and function pointers.
- 08Dynamic Memory
08_dynamic_memory.cmalloc, calloc, realloc, free โ and a small growable array built on top of them.
- 09Structs & Linked List
09_structs_and_linked_list.cStructs, an array of structs, a union, and a full singly linked list.
- 10File I/O & Preprocessor
10_file_io_and_preprocessor.cWriting/reading files with FILE*, a word-count example, and macros with #ifdef.