C Programming: a step-by-step course
29 lessons that take you from your first program to arrays, strings, functions and pointers. Each lesson explains one topic with worked examples. Follow them in order, or jump to any topic.
Start with Lesson 1 →Part 1 · Getting Started
What C is, how a program is structured, and how to think in algorithms and flowcharts. (Lessons 1–5)
1Introduction to C Programming: Overview, Features and Applications
C is one of the most influential programming languages in the history of computing. Even though it was created decades ago, it continues to be widely used for operating…
2The Structure of a C Program: Building Your First BlueprintBefore you can write a single working C program, you need to understand the skeleton every C program is built on. Think of it like learning to write a formal letter —…
3Identifiers, Keywords and Variables: Naming Things in C ProgrammingEvery program you’ll ever write is, at its core, about naming things and storing values in them. A shopping app needs a name for “total price.” A game needs a name for…
4Introduction to Algorithms: Thinking Before You CodeSo far in this course, you’ve learned the building blocks of C — its structure, its naming rules, its variables. But before any of that syntax matters, every programmer…
5Introduction to Flowcharts: Drawing the Logic You Already KnowIn the last post, we wrote twelve algorithms as numbered steps with explicit Go to Step X jumps. That style is precise, but it asks your brain to hold a lot in working…
Part 2 · Data Types, Input/Output and Operators
Store data, read and print it, and combine values with operators. (Lessons 6–12)
6Data Types in C: Choosing the Right Box for Every Value
Back in the “Identifiers, Keywords and Variables” post, we compared a variable to a labeled storage box — and mentioned that every box can only hold one type of item. A…
7Formatted Input and Output in C: Taking Control of printf and scanfYou’ve already used printf() and scanf() throughout this course — but so far, only in their plainest form. Real programs rarely get to print numbers however they land: a…
8Practice Exercise Sheet: Data Types in CCompanion worksheet to “Data Types in C: Choosing the Right Box for Every Value” · Module I · Basics of C
9Operators and Expressions in C: Assignment, Unary, and ArithmeticEvery calculation a C program ever performs — computing a bill total, converting a temperature, working out simple interest — comes down to combining variables and…
10Relational, Logical, and Conditional Operators in CEvery decision a program ever makes — is this number bigger, is the user old enough, is a form completely filled in — depends on operators that answer true or false….
11Bitwise and Special Operators in CEvery value in C — no matter its type — is ultimately just a pattern of bits in memory, as the “Data Types in C” post explained. Most of the operators you’ve used so far…
12Operator Precedence and Associativity in CLook at this line of C: 2 + 3 * 4. What is the answer? If you read left to right like a sentence, you get 5 * 4 = 20. But C says 14. Why? Because C has two sets of rules…
Part 3 · Decisions and Loops
Make choices and repeat work: if, switch, for, while, break, continue and goto. (Lessons 13–18)
13Decision and Case Control: if and if-else in C
Every decision your program will ever make comes down to one basic tool: the if statement. But if on its own has real limits — and understanding exactly where those…
14The switch Statement — and switch vs. if-else LadderThe last post ended with a warning: an if-else-if ladder longer than 5–6 steps starts getting hard to read. switch is C’s answer to exactly that problem — a cleaner way…
15The for Loop: Definite Repetition in CBack in the Algorithms post, several algorithms shared the exact same shape — a counter starting at 1, a condition checking whether to keep going, and a step that moved…
16while and do-while Loops: Indefinite Repetition in CThe for loop is built for definite repetition — you know in advance exactly how many times it needs to run. But plenty of real problems don’t work that way: keep asking…
17break and continue in C: Controlling a Loop from the InsideA normal loop is simple: check the condition, run the whole body, repeat until the condition becomes false. But real problems are not always that tidy. Sometimes you…
18The goto Statement in C: Jumping Around Your ProgramEvery program we have written so far runs from top to bottom. With if, switch and loops we learned to skip some lines or repeat others. C also has a much more direct…
Part 4 · Arrays
One-dimensional and two-dimensional arrays, and matrix operations. (Lessons 19–21)
191-D Arrays in C: Declaration, Address Calculation, Insertion and Deletion
Suppose you want to store the marks of 5 students. With what you know so far, you would write five separate variables: mark1, mark2, mark3, mark4, mark5. Now imagine 500…
20Two-Dimensional Arrays in C: Declaration, Initialization and Accessing ElementsIn the last post we used a 1-D array to store a single list of values, like the marks of one student. But a lot of real data is not a single list. It is a table: marks…
21Matrix Addition and Matrix Multiplication in CIn the last post we saw that a 2-D array is a table of rows and columns. In mathematics, such a table of numbers is called a matrix. Matrices are everywhere: the pixels…
Part 5 · Strings
Character arrays and collections of strings. (Lessons 22–23)
22Strings in C: Working with Character Arrays
So far our arrays held numbers. But a program that only handles numbers is very limited. Names, passwords, addresses, messages and file names are all text, and C stores…
231-D and 2-D Character Arrays in C: Storing Names and WordsThink about the programs you use every day. An attendance register stores the names of 60 students. A phone stores a list of contacts. A restaurant app stores the menu…
Part 6 · Functions and Scope
Split programs into functions and learn where variables live. (Lessons 24–28)
24Functions in C: Declaration and Definition
Imagine a restaurant where one person takes the order, cooks, serves, cleans the tables and prepares the bill. It would be slow, messy, and a single mistake could spoil…
25Categories of Functions in CThink about four people at a shop. One person switches on the lights: no instructions needed, nothing handed back. A second is told which item to pack and packs it,…
26Scope of Variables in CC Programming Series · Variables, Storage, and Visibility
27Call by Value in C: How Parameter Passing WorksImagine you give a friend a photocopy of your notes and she scribbles all over it. Your original notes are untouched. Now imagine you handed over the original notebook…
28Passing Arrays to Functions in C: Search, Sum and SortA teacher keeps the marks of 60 students. She wants one routine to find the total, another to find the topper and another to sort the list. Writing the same loops again and…
Part 7 · Pointers
Addresses, pointers and how to use them safely. (Lesson 29)