π What a Program Actually Is
Before you write a single line of C++, let's make sure you understand what a program even is β not technically, just in plain human terms. Everything else in this entire course builds on this one idea.
A program is a list of instructions that a computer follows, one at a time, in order. That's genuinely it. There's no magic happening inside the machine. The computer does exactly what you tell it β no more, no less. If something goes wrong, it's because an instruction was wrong or missing, not because the computer "misunderstood" you.
A recipe tells you: get two eggs, crack them into a bowl, add salt, whisk, pour into a hot pan, wait two minutes, flip. The steps are in a specific order. Each step depends on the one before it. If you skip "crack the eggs," step 4 ("whisk") doesn't make sense anymore.
A C++ program is the exact same idea, just written in a language a computer can follow instead of a language a person can follow. Every program you'll ever write β from a simple calculator to a video game β is fundamentally just a very long, very precise recipe.
You already know how to click icons, open apps, save files, and use a web browser. Using software and writing software feel like completely different worlds, but the gap is smaller than it looks. When you use an app, someone else already wrote its "recipe" β you're just following the finished result. This course teaches you to write the recipe yourself.
Here's something genuinely reassuring: every program ever written β no matter how complex β is built from a small handful of basic ideas, combined in different ways. This entire "Big Ideas" section covers all of them, in plain English, before you see a single line of actual C++:
Storing Information
Remembering a value to use later
Making Decisions
Doing different things depending on a condition
Repeating Things
Doing the same step multiple times without retyping it
Named Instructions
Giving a group of steps a name you can reuse
That's genuinely the whole list. Every program β a website, a game, a banking system β is these four ideas, combined and layered, over and over, at massive scale.
π¦ Storing Information
The first building block from last lesson. Every useful program needs to remember things β a score, a name, a total β while it runs. Here's what that actually means, before any C++ syntax.
Think of a variable as a labeled box. You put a value inside it β a number, a word, whatever β and you give the box a name so you can find it again later. "Put 5 into a box named score" is exactly what a line of code like int score = 5; means. The name is how you refer to the value later; the box is where the value actually lives while your program runs.
Imagine you write "Phone Number" on a sticky note, and under it, the actual number. Later, you glance at the note labeled "Phone Number" instead of trying to remember the digits yourself. A variable is that same idea: a labeled place to keep a value so your program (and you, reading the code later) can refer to it by a meaningful name instead of remembering the raw value everywhere.
A box meant for whole numbers doesn't sensibly hold a word, and a box meant for text doesn't sensibly hold a decimal number. This is why programming languages β including C++ β have different types of boxes for different kinds of information:
| Kind of Information | Real-World Example |
|---|---|
| A whole number | Someone's age, a score, a count of items |
| A decimal number | A price, a temperature, a measurement |
| Text | A name, an address, a sentence |
| A yes/no value | Is the door locked? Is the game over? |
C++ is unusually strict (compared to some languages) about knowing in advance exactly what KIND of box you're creating β this is a deliberate design choice that catches a whole category of mistakes before your program even runs, which you'll appreciate much more once you've been burned by the alternative.
Unlike a real sticky note you'd have to cross out and rewrite, a variable's value can simply be updated β put a new value in the same labeled box, replacing the old one. Your program might store a score of 0 at the start, then update that exact same box to 10, then 25, as the game progresses. The label (the name) stays the same; what's inside changes.
π Making Decisions
A program that does the exact same thing every single time isn't very useful. This building block is how a program reacts differently depending on the situation.
A decision in code follows one simple shape: check whether something is true, and if it is, do something specific. Optionally, you can also say what to do if it ISN'T true. That's genuinely the whole concept β everything else is just detail on top of "if this, then that, otherwise this other thing."
"If it's raining, bring an umbrella. Otherwise, don't." You check one condition (is it raining?), and your action depends entirely on the answer. You don't bring an umbrella AND not bring one β the condition determines exactly one path. Every decision in a program works the same way: check a condition, follow exactly one resulting path.
A condition a program checks always boils down to something that's either true or false β never "sort of" or "maybe." "Is the score greater than 100?" "Is the door open?" "Did the user type the correct password?" Each of these has exactly one honest answer at any given moment: yes or no. This yes/no nature is precisely what lets the computer make a clean, unambiguous decision.
Real decisions are often more layered than a single yes/no β "if it's raining AND I don't have a car, bring an umbrella AND wear boots. Otherwise, if it's just cold, wear a coat. Otherwise, wear whatever." This is still built from the same basic "if this, then that" idea β just multiple conditions checked in sequence, with the program following whichever path actually matches the real situation.
π Repeating Things
If you needed to do something 1,000 times, would you really want to write the same instruction 1,000 times? This building block is how a program repeats a step without repeating the instruction itself.
A loop lets you write a step (or group of steps) a single time, and tell the computer "now do this again and again" β either a specific number of times, or until some condition (from last lesson!) is no longer true. The computer handles the actual repetition; you only ever write the instruction once.
A trainer doesn't say "do a push-up" 20 separate times. They say "do 20 push-ups" β one instruction, with a repeat count built in. You already know exactly how to follow that instruction. A loop in code is the same idea: one instruction, plus how many times (or under what condition) to repeat it.
| Shape | Real-World Example |
|---|---|
| Repeat a known number of times | "Do 20 push-ups" β you know the count in advance |
| Repeat until a condition changes | "Keep stirring until the sauce thickens" β you don't know exactly how many stirs, you just keep going until the condition (thick enough) becomes true |
Both shapes exist in C++ (you'll meet them properly as for and while loops later in this course) β but conceptually, they're both just "repeat this step, either N times or until something changes."
The real power shows up when you combine last lesson's decisions WITH repetition: "Keep drawing cards until you have a total of 21 or more, but if you ever go over 21, stop and you lose." That single sentence already contains a loop (keep drawing) and a decision (checked every single repetition) working together β and this exact kind of combination is the backbone of almost every real program you'll ever write.
π·οΈ Named Instructions
The last of the four core building blocks. What if a whole GROUP of steps needs to happen over and over, in different places in your program β not just one single instruction?
A function is a named, reusable group of instructions. You write the steps once, give them a name, and from then on, you can run that whole group just by using its name β anywhere in your program, as many times as you want β instead of retyping every step each time.
You don't consciously think through "grind beans, boil water, pour, wait, add milk" as five separate decisions every single morning. You just think "make coffee" β a single named routine that bundles all five steps together. Anyone who understands what "make coffee" means can trigger that whole sequence with one short instruction. A function in code is exactly this: a named bundle of steps you (or your future self, or a teammate) can trigger with one short line.
"Make coffee" is useful, but "make coffee, but with oat milk instead" is more flexible. A function can accept information when it's used β called parameters β that changes exactly how it behaves that specific time, without needing an entirely separate named routine for every possible variation.
A function can also hand a result back to whatever asked it to run β "what's 15% of this restaurant bill?" is a named routine that takes a number in and gives a specific answer back out, rather than just performing an action. This "takes something in, gives something back" pattern is one of the most common and useful shapes a function takes.
Functions are how real programs stay manageable as they grow. Instead of one enormous, tangled list of thousands of steps, a real program is broken into many small, clearly-named functions β each handling one specific job β that call each other in combination. This is also exactly why good naming matters: a function called calculateTax tells you what it does without needing to re-read every step inside it.
π§ How a Computer Reads Code
One last conceptual piece before Section 2 gets your actual computer ready. This is about the computer's mindset β not what it understands, but how mechanically it moves through your instructions.
Unless a decision or a loop (from the last two lessons) says otherwise, a computer reads and runs your code exactly like you'd read a page of text: top to bottom, one instruction at a time, in the order it's written. It doesn't skip ahead, doesn't guess what comes next, and doesn't run two instructions at once by default.
"Turn left on Main Street. Go straight for two miles. Turn right at the gas station." You follow these in order, one at a time β you don't jump to step 3 before finishing step 1. If step 2 said "go straight for two miles, UNLESS you see a detour sign, in which case take the detour" β that's a decision changing your path, exactly like an if statement changes a program's path. But without that kind of instruction, you just go top to bottom.
This is the single most important mindset shift for a beginner. A computer doesn't guess what you probably meant, and it doesn't fill in gaps using common sense. If your instructions say to do something in an order that doesn't actually make sense β like using a variable's value before you've ever given it one β the computer will do exactly that broken thing, not politely correct your mistake for you.
When you talk to a person, "kind of," "sort of," and "probably" are perfectly normal. A computer has no tolerance for that kind of vagueness β an instruction either says exactly what to do, or it doesn't compile or run at all. This isn't the computer being unreasonably strict for no reason; it's simply what "no guessing, no assumptions" requires in practice. You'll get comfortable with this precision quickly β it becomes second nature within your first few real programs.
βοΈ What a Compiler Actually Does
Here's where this course genuinely earns its "for someone who's never touched a compiler" promise. C++ has an extra step that some other languages hide from you β and understanding it now will save you real confusion later.
Broadly, programming languages fall into two camps for how they actually run:
| Kind | How It Runs | Example |
|---|---|---|
| Interpreted | Another program reads your code and carries out each instruction "live," on the spot, every time you run it | Python, JavaScript |
| Compiled | A separate program translates your entire code, once, into a form the computer's processor can run directly β before you ever run it | C++, C, Rust |
C++ is compiled. This is the single biggest practical difference you'll notice coming in with no prior experience: you don't just "run" your C++ code directly. You compile it first, and THEN run the result.
An interpreter at a live event translates what's said, sentence by sentence, in real time, as the speaker talks. A book translator instead takes the entire original book and produces a complete translated book β a finished, separate product β before anyone reads a single page of it. A compiler works like the book translator: it takes your ENTIRE C++ program and translates all of it, up front, into a separate, ready-to-run program. Only after that translation finishes do you actually run anything.
The code you'll write is genuinely readable by a person (once you know the syntax) β words like if, while, and meaningful variable names. But a computer's processor doesn't actually run that text directly; it only runs extremely low-level binary instructions called machine code. The compiler is the program that bridges this gap: it reads your human-readable C++ source code and produces the machine code your specific computer can actually execute.
Every single time you change your code, you'll repeat the same three-step cycle: write (edit your source code), compile (translate it into a runnable program), run (actually execute it and see what happens). If the compiler finds a mistake in your code, it stops and shows you an error instead of producing a runnable program at all β you fix the mistake, and compile again. Lesson 12 covers exactly how to read those error messages without panicking.
π§ Installing Your Toolchain
Time to actually set up your computer. This lesson walks through getting a real C++ compiler and editor installed β the two things you genuinely need before writing a line of code.
| Tool | What It's For |
|---|---|
| A compiler | Translates your C++ code into a runnable program (Lesson 7) |
| An editor or IDE | Where you actually type and organize your code β ranges from a simple text editor up to a full Integrated Development Environment with built-in error-checking, auto-complete, and a debugger |
This course recommends installing an IDE rather than a bare text editor, specifically because an IDE bundles helpful features (like catching simple mistakes as you type) that make the very beginning of your C++ journey noticeably less frustrating.
| OS | Recommended Setup |
|---|---|
| Windows | Install Visual Studio Community (free) β it bundles Microsoft's compiler and a full IDE in one installer, and is the most beginner-friction-free path on Windows specifically |
| macOS | Install Xcode Command Line Tools (provides the clang compiler) from the App Store or via Terminal, then use an editor like VS Code or CLion |
| Linux | Install the g++ compiler through your distribution's package manager (for example, sudo apt install g++ on Ubuntu/Debian), then use an editor like VS Code or CLion |
After installing, the most reliable way to confirm everything's actually working is to check your compiler's version from a terminal (Lesson 9 covers terminals properly, but here's a preview): open a terminal window and type g++ --version (or clang++ --version on macOS). If a version number prints back, your compiler is correctly installed and ready. If you instead see an error like "command not found," the installation didn't complete correctly, or the compiler isn't on your system's PATH β a very common first hurdle, and not a sign you did anything unusually wrong.
Toolchain installation is, honestly, one of the most common places beginners get stuck β often before they've written a single line of actual code. If something doesn't work on the first try, that's completely normal and not a reflection of your ability to learn C++. Searching your exact error message plus your operating system is a genuinely effective troubleshooting strategy, and one you'll keep using throughout your entire programming career, not just here.
β¨οΈ The Terminal, Just Enough
If you've only ever used a computer by clicking icons, a black screen full of typed text can feel intimidating. This lesson covers exactly enough to get you comfortable β not a deep dive, just what you'll actually use.
Everything you've done on a computer so far β opening apps, moving files β has a typed equivalent. A terminal (also called a command line or console) is a program where, instead of clicking, you type the name of what you want to do. It's not a more "advanced" computer underneath β it's the same computer, just a different way of telling it what to do, and one that happens to be how you'll compile and run C++ programs throughout this entire course.
| OS | How to Open It |
|---|---|
| Windows | Search for "Command Prompt" or "PowerShell" in the Start menu |
| macOS | Search for "Terminal" using Spotlight (Cmd+Space, then type "Terminal") |
| Linux | Usually Ctrl+Alt+T, or search for "Terminal" in your applications menu |
Most IDEs (including Visual Studio and CLion) also have a terminal built directly into the application window, so you may not even need to open a separate one once your editor is set up.
| Command | What It Does | Example |
|---|---|---|
pwd (Mac/Linux) / cd alone (Windows) | Shows which folder you're currently "in" | pwd |
ls (Mac/Linux) / dir (Windows) | Lists the files and folders in your current location | ls |
cd folder-name | Moves into a folder ("change directory") | cd projects |
cd .. | Moves back up one folder level | cd .. |
- Press Tab to auto-complete. Start typing a file or folder name and press Tab β most terminals will finish it for you, saving typing and avoiding typos.
- Press the Up arrow to reuse a previous command instead of retyping it.
- Capitalization and exact spelling matter. A terminal won't guess what you meant the way a search engine might.
π Files, Folders & Paths
You already understand files and folders from everyday computer use. This lesson connects that existing knowledge to how you'll organize and locate your actual C++ projects.
A C++ program starts as a plain text file β genuinely no different in kind from a .txt file, just saved with a .cpp extension instead, which tells your compiler and editor "this text is C++ code." You'll create, save, rename, and organize these files exactly like any other file you've ever worked with β the only new part is what you'll type inside them.
Just like you might keep a folder for photos and a separate one for documents, you'll want a dedicated folder for your C++ projects β commonly something like a folder named cpp-projects inside your Documents. Inside that, most people create a separate subfolder for each individual program or project, keeping related files together and separate from unrelated ones.
A path is just the full set of directions to a specific file or folder, written out β the same information you'd give someone verbally ("it's in Documents, then cpp-projects, then hello-world"), just written in a compact, standard format.
| Type | What It Means | Example |
|---|---|---|
| Absolute path | The complete route from the very top of your file system | /Users/yourname/Documents/cpp-projects/hello-world/main.cpp |
| Relative path | Directions starting from wherever you currently are | cpp-projects/hello-world/main.cpp (if you're already in Documents) |
cd cpp-projects uses a relative path β "go into the folder named cpp-projects, starting from wherever I already am." Understanding paths is what makes terminal navigation actually make sense, instead of feeling like memorized magic words.Both Windows and macOS hide file extensions (the .cpp, .txt part) by default in their file browsers β genuinely useful for casual computer use, but actively unhelpful once you're writing code, since you'll frequently need to see and confirm exact file extensions. It's worth turning this setting on now: search "show file extensions" plus your operating system for quick, current instructions.
π From English to C++
Every concept in Section 1 is about to get its real C++ syntax for the first time. Nothing here is new IDEA-wise β you already understand every one of these β this is purely translation.
Remember the "labeled box" from Lesson 2? In C++, creating one looks like this:
int score = 5; double price = 19.99; std::string name = "Alex";
Read the first line as: "Create a whole-number box named score, and put 5 in it." int is the TYPE of box (whole numbers), score is the label, and = 5 is what goes inside. The semicolon simply marks "this instruction is finished" β C++ uses it to know where one instruction ends and the next begins, since (unlike English) it doesn't rely on line breaks alone.
if (score > 100) { // do this if the condition is true } else { // do this otherwise }
This is precisely "if it's raining, bring an umbrella, otherwise don't" from Lesson 3 β if (condition) introduces the check, the curly braces { } group together everything that should happen for that branch, and else covers the "otherwise" case.
for (int i = 0; i < 20; i++) { // do this 20 times }
This is "do 20 push-ups" from Lesson 4. You'll learn exactly what each of the three parts inside the parentheses means in Module 2 β for now, just recognize the shape: a loop repeats whatever's inside its curly braces.
int calculateTax(double price) { return price * 0.08; }
This is "make coffee" from Lesson 5 β a named routine (calculateTax) that takes information in (price) and gives a result back (return). You'll call this named routine elsewhere in your program just by writing calculateTax(19.99).
{ } is how you group a set of instructions together β whether that's "everything that happens if this condition is true," "everything that repeats in this loop," or "everything inside this named routine." It's the same grouping idea, reused consistently across every one of the Big Ideas.{ } generally represent across C++ code?π Your First Real Program
Everything so far has been concept and setup. This lesson is where you actually write, compile, and run a real C++ program β the classic first step, done for real on your own machine.
Using your project folder from Lesson 10, create a new file named exactly main.cpp inside a fresh folder (something like cpp-projects/hello-world/). Open it in your editor or IDE from Lesson 8, and type the following exactly as shown:
#include <iostream> int main() { std::cout << "Hello, world!" << std::endl; return 0; }
| Line | What It Does |
|---|---|
#include <iostream> | Brings in the tools for input/output (like printing text to the screen) β C++'s core language doesn't include this by itself, so you explicitly ask for it |
int main() { | Every C++ program needs exactly one function named main β it's the specific named routine (Lesson 5!) the program starts running from, automatically, every time |
std::cout << "Hello, world!" << std::endl; | Prints the text "Hello, world!" to the screen, then moves to a new line |
return 0; | Tells the operating system the program finished successfully (0 conventionally means "no errors") |
} | Closes the curly brace that opened with main() β marking the end of that function's instructions |
Open a terminal (Lesson 9), navigate to your project folder using cd, and run:
g++ main.cpp -o hello
Read this as: "compiler, translate main.cpp, and name the resulting program hello." If nothing prints back and you're returned to a normal prompt, it worked β no news is good news here. A new file (on Mac/Linux, named hello; on Windows, hello.exe) now exists in that same folder.
./hello
(On Windows, just type hello without the ./.) You should see Hello, world! printed to your screen. If you see that β genuinely, congratulations. You just wrote, compiled, and ran a real C++ program, from nothing, on your own machine.
int main() {?π©Ή Reading an Error Message
You will see compiler errors. Constantly, forever, at every experience level β this never fully goes away, and that's completely normal. This lesson makes them far less intimidating.
A C++ compiler error can look like a dense wall of unfamiliar text. But underneath the intimidating formatting, it's always trying to tell you exactly three things: which file the problem is in, which line it's on, and what specifically the compiler couldn't understand. Once you know to look for those three pieces, the wall of text becomes much more approachable.
Suppose you accidentally forgot a semicolon:
int score = 5 int total = 10;
The compiler might respond with something like:
main.cpp:2:1: error: expected ';' after top level declarator
int total = 10;
^
;
| Part | What It Tells You |
|---|---|
main.cpp:2:1 | File name, then line 2, then column 1 β exactly where the compiler got confused |
error: | This is a genuine problem, not just a suggestion β your program will not compile until it's fixed |
expected ';' after top level declarator | The compiler's description of what it expected to find and didn't |
The ^ and the code snippet | A visual pointer showing roughly where, in your actual code, the problem was detected |
- Find the file and line number β go directly there in your editor.
- Read the error description slowly β it's often more literally accurate than it first feels.
- Check the line above, too β per the callout above.
- If you're stuck, search the exact error text β copy the core error message (not your specific variable names) into a search engine. This is a completely normal, universally-used technique, not a sign of inexperience.
β You're Ready
Let's take stock of everything covered before Phase 1 begins. You've come a genuinely long way from "only knows how to use a PC."
Storing Information
What a variable is, and why types matter
Making Decisions
How "if this, then that" actually works
Repeating Things
Loops, and both shapes they take
Named Instructions
Functions, parameters, and return values
Plus the mechanical skills that make all four of those actually usable: what compiling means, a working C++ toolchain installed on your own machine, enough terminal command to navigate confidently, understanding files/folders/paths, and β critically β the ability to read a compiler error without panicking.
You've already done the two things that stop most people before they really start: you got a real compiler working on your own computer, and you compiled and ran a real program successfully. Everything from here is deepening skills you've already started using β not starting from zero again.
Phase 1 (C++ Fundamentals) picks up exactly where this Pre-Course leaves off β the same four Big Ideas, now explored in real depth with real C++ syntax: every data type, every operator, proper input with cin, and enough practice to make writing a variable declaration feel automatic instead of something you have to think through step by step.
One Small Modification
Go back to your hello-world project from Lesson 12. Change the program to print your own name instead of "world," then recompile and run it again. This sounds trivial β but doing it yourself, end to end, one more time, is exactly the repetition that turns "I followed along" into "I can actually do this."
- Open
main.cppin your editor - Change the text inside the quotes
- Save the file
- Recompile with
g++ main.cpp -o hello - Run it again with
./helloand confirm your change actually shows up