This book is an introduction to programming using C++. I assume that the reader has no previous programming experience. My goal is to focus on 'worked' coding examples to explain how to program. Most of what I write will be in the context of a code example. The code will always be the priority but I have also added text, pictures, screenshots, and videos that refer to the code.
These examples are called code playbacks. They animate the construction of some code that I have written. I will use them to show how a program grows from an empty file to a functioning program. I will explain the basics of C++ programming by telling the story of how programs grow. For each of the playbacks below simply click on the comments on the left hand side of the screen to move through the code.
| 1.1 Name printer program |
| 1.2 Distance formula |
| 1.3 Basic types in C++ |
| 1.4 Number types |
| 1.5 Characters and strings |
| 1.6 Weekly pay calculator |
| 1.7 Distance formula revisited |
| 1.8 Gas Mileage |
| 2.1 Booleans |
| 2.2 Even/odd calculator |
| 2.3 Overtime pay with an if/else |
| 2.4 Water temperature |
| 2.5 Switch |
| 3.1 A simple loop |
| 3.2 More loops |
| 3.3 Summation |
| 3.4 Nested loop |
| 3.5 for loop |
| 3.6 Capitalization |
| 3.7 break and continue |
| 4.1 Arrays |
| 4.2 Average and standard deviation of an array of values |
| 4.3 Problems with arrays |
| 4.4 Flipping coins |
| 4.5 Multi-dimensional arrays |
| 5.1 Functions |
| 5.2 Value returning functions |
| 5.3 Functions with parameters |
| 5.4 Passing parameters by reference |
| 5.5 The scope of variables |
| 5.6 Prime number function |
| 5.7 Passing arrays to functions |
| 7.1 Simple struct |
| 7.2 Hierarchical structs |
| 7.3 Vectors as members of structs |
| 7.4 structs with a vector of objects |
| 7.5 Calculus with structs |
| 10.1 Simple Linked List |
| 10.2 Simple Hash Table |
| 10.3 Hash Table |
| 10.4 An Example of an unordered_map (Hash Table) |
| 10.5 Binary Search Tree |
| 10.6 Graph Adjacency Matrix |