How Computers Run Programs
What a program actually is, why programming languages exist, and what a compiler does — no code required yet.
Before writing any C++, let's answer the most basic question: what is a program?
A program is a list of instructions that a computer follows, one after another, exactly as written. That's it. Every app on your phone, every game, every website is — underneath everything — a very long list of small instructions.
Think of a cooking recipe:
1. Preheat the oven to 180°.
2. Mix flour and sugar.
3. Bake for 25 minutes.
A recipe is instructions for a cook. A program is instructions for a computer. The big difference: a cook can improvise when a step is unclear. A computer cannot. It does exactly what the instructions say — nothing more, nothing less.
Deep down, a computer's processor (the CPU) only understands machine code — long sequences of 1s and 0s like 10110000 01100001. Nobody wants to write that by hand.
That's why programming languages exist. A programming language lets you write instructions in something close to English:
cout << "Hello!";Text written in a programming language is called source code (or just code). It's for humans to read and write. The computer still needs it translated into machine code before it can run — and that's the job of a special tool you'll meet next.
What is a program?
- AA list of instructions that a computer follows exactly, in order
- BA description of what a computer should roughly try to do
- CThe physical parts inside a computer
- DA file that only contains text for humans to read
The tool that translates your source code into machine code is called a compiler.
Here's the full journey of a C++ program:
1. You write source code — human-readable text in a file like hello.cpp.
2. The compiler translates it — the whole file at once — into machine code, producing an executable (a runnable program, like hello.exe).
3. The computer runs the executable — directly on the CPU, at full speed.
Three words to remember, because they come up constantly:
- Source code — the instructions you write.
- Compiler — the translator.
- Machine code — the 1s and 0s the CPU actually runs.
You wrote some instructions and the program's result is wrong. What's the most likely reason?
- AThe computer misunderstood what you meant
- BThe instructions you wrote don't say what you intended them to say
- CThe computer decided to do something different
- DMachine code is unreliable
One more thing before we start: errors are a normal part of programming.
When your code has a typo or breaks a language rule, the compiler refuses to translate it and prints an error message instead. This is not failure — it's the compiler helping you, pointing at problems before the program ever runs.
Every professional programmer sees compiler errors every single day. In this course you'll learn to read them calmly, fix the code, and try again. That write → compile → fix cycle is programming.
Next up: why, out of hundreds of programming languages, C++ is the one behind the world's fastest software.
The tool that translates human-readable source code into machine code is called a ___.