Sign up to track your progress
Create an account to save your progress, complete exercises, and earn achievements.
ANSI C (C89)
The classic ANSI C university syllabus, taught in its traditional order from tokens and operators through arrays, strings, functions, structures, pointers, files, and linked lists. Every program you write is compiled as strict C89 with pedantic errors, exactly the dialect old exam papers assume, but written correctly: real prototypes, checked return values, safe input, and AddressSanitizer verifying every run. Includes exam notes wherever old compilers and question papers differ from what the language actually guarantees.
This course is in beta. You get early access while we're still writing and refining it, so lessons may change, and new content is added regularly. Spotted a problem? Feedback is welcome.
Support Free C++ Education
Help us keep this platform free for everyone! Your support enables us to create more high-quality lessons, exercises, and interactive content.
Course Curriculum
Getting Started with C (4 lessons)
How a C program goes from source file to running executable, the anatomy of main, and your first complete programs compiled and run with gcc.
How a Computer Runs Your Program
What source code, the compiler, the linker, and the executable each are, and the journey a .c file takes before the machine can run it.
20 minutes
The Anatomy of a C Program
The sections of a C source file, what main is, printing with printf, and compiling and running your first program with gcc.
25 minutes
Variables, Input, and a First Real Program
Declare variables, read values with scanf, and put both together in a complete interest calculation program of the kind every C exam opens with.
30 minutes
Chapter 1 Summary and Quiz
Recap of the compile-and-run pipeline, program anatomy, and first programs.
15 minutes
Constants, Variables, and Data Types (6 lessons)
The tokens C programs are built from, the basic types and their sizes, constants in all their literal forms, enumerations for naming a set of them, and a first look at storage classes.
Tokens, Keywords, and Identifiers
The C character set, the token kinds the compiler sees, reserved keywords, and the rules for naming identifiers.
20 minutes
Data Types and Their Sizes
int, char, float, double, signed and unsigned variants, sizeof, and why exam papers built on 16-bit compilers quote different sizes than your machine prints.
30 minutes
Constants and Symbolic Names
Integer, floating, character, and string literals, const-qualified variables, and #define symbolic constants and when to use each.
25 minutes
Enumerations
enum for naming a set of related integer constants: numbering from zero, explicit values, why an enum constant is just an int, and the compile-time constant C otherwise lacks.
25 minutes
Storage Classes: A First Look
What auto, static, extern, and register mean on a declaration, previewed here because exam papers ask early; the full story arrives with functions.
20 minutes
Chapter 2 Summary and Quiz
Recap of tokens, types, sizes, constants, and storage class keywords.
15 minutes
Operators and Expressions (6 lessons)
Every operator family in C, how expressions are evaluated and converted, and the precedence and associativity rules exam questions love to probe.
Arithmetic, Relational, and Logical Operators
The core operator families, integer versus floating division, the modulo operator, and how relational results are just ints.
25 minutes
Assignment, Increment, and Conditional Operators
Compound assignment, prefix and postfix ++ and --, the ternary operator, and why classic exam expressions like i++ + ++i have no defined answer.
30 minutes
Bitwise and Special Operators
Shifts, AND, OR, XOR, complement, plus the comma operator and sizeof as an operator.
25 minutes
Precedence, Associativity, and Type Conversions
How C decides evaluation order on paper, implicit arithmetic conversions, and explicit casts.
30 minutes
The Math Library and Numerical Hazards
math.h and the -lm link step, floating point round-off and why == fails on doubles, and the arithmetic C leaves undefined: division by zero and signed overflow.
25 minutes
Chapter 3 Summary and Quiz
Recap of the operator families, conversions, and precedence rules.
15 minutes
Input and Output (4 lessons)
The standard I/O toolkit: character I/O with ctype.h, the full printf format language, and scanf used with its widths, its scansets, and its return value checked like it always should be.
Character I/O with getchar and putchar
Reading and writing one character at a time, EOF, classifying and converting characters with ctype.h, and a first taste of loops over input.
30 minutes
Formatted Output with printf
Conversion specifiers, field width, precision, and every flag, with the exact-output discipline exams and this platform both demand.
35 minutes
Formatted Input with scanf
Conversion specifiers on input, why arguments need &, the whitespace rules, field widths and skipped fields, scansets, and treating the return value as the conversion count it is.
45 minutes
Branching (4 lessons)
Choosing between paths: if in all its forms, switch, the conditional operator as a branch, and goto covered honestly because the syllabus includes it.
if and the else-if Ladder
Simple if, if-else, nesting, the else-if ladder, and the dangling-else rule that decides which else binds where.
30 minutes
switch Statements
The switch statement, case labels, fallthrough as both a bug and a tool, and default.
25 minutes
goto and Structured Alternatives
What goto does, the one cleanup pattern where C programmers still accept it, and the structured forms that replace it everywhere else.
20 minutes
Loops (4 lessons)
Repetition with while, do-while, and for, controlling loops with break and continue, and the nested-loop patterns behind every exam pattern-printing question.
while and do-while
Entry-controlled versus exit-controlled loops, sentinel-driven input loops, and choosing between the two forms.
25 minutes
The for Loop
The three-part header, counting up and down, and the idioms that make for the default counting loop.
25 minutes
break, continue, and Nested Loops
Leaving early, skipping an iteration, and the nested loops behind matrix traversal and the pattern-printing questions on every paper.
30 minutes
Arrays (4 lessons)
Contiguous storage in one, two, and more dimensions, initialization rules, why C never checks your index, and the classic searching and sorting algorithms.
One-Dimensional Arrays
Declaring, initializing, and traversing arrays, counting with a computed index, and why an out-of-bounds index is undefined behaviour rather than an error message.
35 minutes
Two-Dimensional Arrays
Matrices in row-major storage, nested-loop traversal, the matrix addition and multiplication programs exams expect, and how the rules generalize to three dimensions and beyond.
45 minutes
Classic Array Algorithms
Linear search, binary search, and bubble sort, written cleanly and traced by hand the way an examiner asks.
30 minutes
Character Arrays and Strings (5 lessons)
Strings as char arrays with a null terminator, reading them safely, the string library functions plus hand-written versions of each, and tables of strings for lists of names.
Strings and the Null Terminator
What a C string actually is in memory, string literals, and the difference between length and size.
25 minutes
Reading and Printing Strings
printf with %s, scanf's %s and its buffer-overrun trap, fgets as the safe reader, and why gets no longer exists in the language.
30 minutes
The String Library
strlen, strcpy, strcat, and strcmp, then writing each one yourself, the exam question that never goes away.
30 minutes
Tables of Strings
Two-dimensional char arrays as lists of names, why one subscript names a whole string, and sorting a name list with strcmp and strcpy.
30 minutes
Functions (5 lessons)
User-defined functions, prototypes, pass-by-value, recursion, and the full story on scope, lifetime, and storage classes.
Defining and Calling Functions
Function definitions, prototypes and why they matter, return types, and void functions and parameters.
30 minutes
Pass by Value
Every argument is a copy: what that means, what it forbids, and the swap function that fails because of it.
25 minutes
Recursion
Base case and recursive case, factorial, Fibonacci, and tracing the calls the way an exam answer requires.
30 minutes
Scope, Lifetime, and Storage Classes
Block scope and file scope, static locals that survive between calls, extern across files, and register as history.
30 minutes
Structures and Unions (5 lessons)
Grouping related data with struct, arrays of records, passing structures to functions, and unions and bit-fields.
Defining Structures
Struct declarations, members, initialization, the dot operator, and typedef for cleaner names.
25 minutes
Arrays of Structures
Record-keeping programs: an array of student records, sorted and searched, the staple of every structures question.
30 minutes
Structures and Functions
Passing structures by value, returning them, and when copying a struct starts to cost.
25 minutes
Unions and Bit-Fields
How a union overlays its members, what reading the wrong member means, and bit-fields for packed flags.
25 minutes
Pointers (5 lessons)
Addresses as values: declaring pointers, pointer arithmetic over arrays, passing addresses to functions, and pointers with strings and structures.
Pointer Basics
Declaring a pointer, the address-of and dereference operators, NULL, and drawing the memory picture that makes pointers ordinary.
30 minutes
Pointers and Arrays
Pointer arithmetic, why a[i] is *(a+i), array decay in function calls, and the limits the standard puts on arithmetic.
30 minutes
Pointers and Functions
Passing addresses so a function can modify the caller's variables: swap done right, and out-parameters as C's second return value.
30 minutes
Pointers with Strings and Structures
char pointers versus char arrays, walking a string by pointer, pointers to structures, and the arrow operator.
30 minutes
Chapter 11 Summary and Quiz
Recap of pointers across arrays, functions, strings, and structures.
15 minutes
File Handling (5 lessons)
Persistent data with the FILE API: opening and closing with every error checked, text and binary I/O, random access, and command-line arguments.
Opening and Closing Files
fopen and its modes, why the NULL check is not optional, fclose, and what a FILE pointer represents.
25 minutes
Reading and Writing Text Files
fgetc, fputc, fgets, fprintf, and fscanf, with end-of-file handled correctly.
30 minutes
Binary Files and Random Access
fread and fwrite on records, fseek and ftell, and when binary beats text.
30 minutes
Command-Line Arguments
argc and argv: where they come from, converting argument strings to numbers, and validating what the user typed.
20 minutes
Dynamic Memory and Linked Lists (4 lessons)
Requesting memory at run time with malloc, calloc, realloc, and free, then spending it on the linked list every syllabus culminates in.
malloc, calloc, realloc, and free
The allocation functions, checking every return, ownership as a discipline, and what a leak looks like under AddressSanitizer.
30 minutes
Building a Linked List
Self-referential structures, allocating nodes, linking them, and printing the list.
30 minutes
Insertion and Deletion
Inserting at the head, the tail, and mid-list, deleting a node without leaking it, and freeing the whole list.
30 minutes
The Preprocessor (3 lessons)
The text-substitution pass before compilation: macros and their traps, file inclusion, and conditional compilation.
Macros and File Inclusion
#define for object-like and function-like macros, the parenthesization traps, #include, and macros versus functions.
30 minutes
Conditional Compilation
#ifdef, #ifndef, #if, include guards, and using them to compile different code for different situations.
25 minutes
Writing Real Programs (4 lessons)
Bringing the course together: structuring a larger program, the honest map between exam C and modern C, and a complete record-management capstone.
Structuring a Larger Program
Top-down design, splitting work into functions, naming, and the habits that keep a 300-line program readable.
25 minutes
Exam C versus Modern C
void main, conio.h, gets, 2-byte int, and undefined-behaviour output questions: what old exam papers expect, what is actually correct, and how to answer both ways with your eyes open.
30 minutes
Capstone: A Records Manager
A complete menu-driven student records program using structs, dynamic memory, files, and every check the course taught.
45 minutes
Chapter 15 Summary and Quiz
Recap of the whole course, plus the craft that has no lesson of its own: the four kinds of error, testing against designed data, the three ways to locate a bug, a checklist of C's classic traps, and when program efficiency is worth caring about.
30 minutes