C exercises
Exercises with full test sets for C are being written and verified. Until they are published, every lesson ends with a short program to write, with its expected output.
- C Syntax and Your First ProgramThe parts of a C program: #include, int main(void), statements, braces, comments and printf, plus how gcc turns the source file into a program you can run.8 min
- Variables and Types in CDeclaring C variables and choosing types: int, long, double, char and bool, sizeof, why uninitialised variables hold garbage, and printf and scanf specifiers.9 min
- Operators in CC arithmetic, comparison, logical, assignment and increment operators: why 7 / 2 is 3, how % behaves, what comparisons return, precedence and = versus ==.9 min
- Conditions in C: if, else and switchHow C chooses between branches with if, else if, else and switch: what counts as true, combining tests with && and ||, and why each switch case ends with break.9 min
- Loops in C: for, while and do-whileThe three C loops and when each fits: how a for loop's three parts run, reading input until it ends with while and scanf, and using break and continue safely.9 min
- Functions in CHow to define and call C functions: prototypes before the first call, arguments copied by value, void functions, early returns and local variables.10 min