Introduction to C++
Read at your own pace. Code execution, quizzes, progress tracking, and the AI tutor are available in the interactive view with JavaScript enabled.
Welcome to C++
Why this lesson matters
This is our first step into C++: a language famous for speed, control, and real-world reach.
If you come from web development, you may be used to writing JavaScript or working with frameworks where many details are handled for you. C++ brings you closer to how computers actually run programs.
In this lesson, we will answer:
- What is C++?
- Why do engineers still choose it?
- What does a tiny C++ program look like?
- How does source code become something your computer can run?
Later lessons will build from this foundation into variables, control flow, functions, object-oriented programming, the STL, and real-world applications.

What Is C++?
A language between worlds
C++ is often called a middle-level language because it gives you both:
- High-level tools for organizing large programs
- Low-level control over memory, performance, and hardware-like details
It began in 1979 as an extension of the C programming language. The original idea was roughly: keep C's efficiency, but add better tools for building large software systems.
That combination is why C++ shows up in places where performance matters:
- Game engines
- Trading systems and financial infrastructure
- Databases
- Browsers
- Embedded systems
- AI and machine learning runtimes
C++ is not just about writing code that works. It is about understanding what your code costs.

Compiled, Not Interpreted
From source code to executable
Many web developers first meet languages that run through an interpreter or runtime environment. C++ is usually different: it is a compiled language.
A typical workflow looks like this:
C++ source code → compiler → executable program → output
The compiler checks your code and translates it into machine instructions your computer can run.
This matters because compilation can produce very fast programs, but it also means C++ tends to be strict. Small syntax issues, such as missing punctuation, can stop the program before it runs.
That strictness can feel demanding at first, but it is also one of the reasons C++ is valued in systems where correctness and performance matter.

Your First Program
Hello from C++
Here is a complete C++ program.
A few things to notice:
-
#include <iostream>brings in console input/output tools. -
int main()is where the program starts running. -
std::coutprints text to the console. -
return 0;signals that the program finished successfully.
Do not worry about memorizing every symbol yet. For now, focus on the shape: C++ programs have structure, and the computer starts from main.
```cpp
#include <iostream>
int main() {
std::cout << "Hello from C++!" << std::endl;
std::cout << "This program was compiled and run." << std::endl;
return 0;
}
```
Program Entry Point
In a basic C++ program, which function is the usual starting point where execution begins?
Performance Mindset
Why C++ can be fast
C++ is associated with performance because it gives programmers control over details that many languages hide.
That does not mean every C++ program is automatically fast. It means C++ gives you the tools to make careful tradeoffs.
Useful mental model:
More control → More responsibility
More abstraction → More convenience
For example, a financial trading system may care about tiny timing differences. A game engine may need to update thousands of objects per frame. An AI runtime may need to move huge amounts of data efficiently.
C++ is popular in these areas because it lets engineers reason about both the algorithm and the machine running it.

Runtime Style
C++ programs are usually interpreted line by line by the browser in the same way client-side JavaScript is.
Reading C++ Shape
Syntax has visual patterns
C++ can look symbol-heavy at first, but the structure becomes familiar quickly.
In this example, pay attention to the repeated shape:
std::cout << "some text" << std::endl;
You can read it as: send this text to the console, then end the line.
C++ also uses semicolons to finish many statements. That is one reason compiler errors often point to punctuation, braces, or missing includes.
```cpp
#include <iostream>
int main() {
std::cout << "C++ programs are made of statements." << std::endl;
std::cout << "Many statements end with semicolons." << std::endl;
std::cout << "The main function controls the starting flow." << std::endl;
return 0;
}
```
Compile Step
A program that translates C++ source code into an executable form is called a ____.
A C++ Attitude
Think like a builder
C++ rewards careful thinking. You are not only asking, "Does this work?" You are also learning to ask:
- What is the program doing?
- What does the machine need to run it?
- Is the structure clear?
- Could this scale to a larger system?
That mindset is useful whether you are building a trading engine, studying algorithms, writing backend services, or exploring AI infrastructure.
Here is a tiny program that prints the themes of this course.
```cpp
#include <iostream>
int main() {
std::cout << "C++ theme 1: write clear programs." << std::endl;
std::cout << "C++ theme 2: understand performance." << std::endl;
std::cout << "C++ theme 3: build from fundamentals." << std::endl;
return 0;
}
```
Big Picture Check
Which statement best captures why C++ is still widely used?