Skip to content
Stage 1: Absolute Beginner8 minAny (concepts only)

Introduction to programming and C++

Focus timer

25:00

In this lesson you will

  • Explain what C++ is and where it is used
  • Understand the difference between source code and a compiled program
  • Know what a compiler does

Background theory for this stage

C++ is a compiled language: a compiler turns your source text into machine code before the program runs. That is why C++ programs start fast and run close to the speed of the hardware.

Every value in C++ has a type (int, double, char, bool…) fixed at compile time. Types tell the compiler how much memory to reserve and which operations are allowed, so many mistakes are caught before the program ever runs.

Used in real jobs: Every C++ job — games, embedded devices, finance, browsers — starts with these basics of types, variables, input and output.

C++ history, jobs and career scope →

C++ in one sentence

C++ is a general-purpose programming language created by Bjarne Stroustrup in the early 1980s as an extension of the C language. It lets you write programs that run very fast while still giving you tools to organise large projects.

It is used for games, web browsers, operating systems, databases, robotics, trading systems and many other programs where speed and control over memory matter.

Source code and compiling

You write C++ as plain text in files ending in .cpp. This text is called source code. Your computer cannot run source code directly.

A compiler is a program that translates your source code into machine code, a file your computer can execute. If your code breaks the rules of the language, the compiler stops and shows an error message instead.

cpp
your_program.cpp  --(compiler)-->  your_program.exe  --(run)-->  output

Why learn C++?

Learning C++ teaches you how computers really work: memory, performance and types. Those ideas make learning any other language easier later.

C++ is also standardised. New versions (C++11, C++14, C++17, C++20, C++23) add features while keeping old code working.

Explain it back

What does a compiler do?

Translates source code into machine code

A compiler translates your human-readable source code into machine code the computer can execute.

Which file extension is commonly used for C++ source files?

.cpp

.cpp is the most common extension. .exe is a compiled program on Windows, not source code.

Who created C++?

Bjarne Stroustrup

Bjarne Stroustrup created C++. Dennis Ritchie created C.

Common mistakes

  • Thinking C++ and C are the same language.

    C++ grew out of C and can use most C code, but adds classes, templates, references, the standard library and much more.

  • Expecting a .cpp file to run by double-clicking it.

    Source code must be compiled first. The compiler produces the runnable program.

Where you'll use this

  • Game engines such as Unreal Engine
  • Web browsers (Chrome, Firefox)
  • Operating systems, databases and embedded devices

Revision summary

  • C++ is a fast, compiled, general-purpose language.
  • A compiler turns .cpp source code into a runnable program.
  • Compiler errors are helpful messages, not failures.

Knowledge check

1. What does a compiler do?
2. Which file extension is commonly used for C++ source files?
3. Who created C++?

Hands-on practice

Output challenge · 20 XP

// OUTPUT CHALLENGE

Your first build

Print "Hello, C++!" followed by a newline.

Greeting

Expected: Hello, C++!
Compiler Explorer / Wandbox · C++17

Related notes

  • Compile and run

    Source code must be compiled before it can run.

  • The main function

    Execution starts at int main().

All notes