Courses
Playgrounds

C++ Fundamentals

43 lessons16 exercisesC++

A first course in C++, taught from first principles: types, control flow, functions, arrays, strings, vectors, pointers and references, with runnable code examples, quizzes and exercises, all in your browser.

Start Course

Course Description

This course takes you from your first C++ program to working directly with memory. You’ll start with how a C++ program is structured, compiled and run, then move on to variables and types, operators, input and output, control flow and functions. From there you’ll work with arrays, C-style strings, std::string, std::array and std::vector, and finish with pointers, references and the bugs they can cause, such as dangling pointers.

Object-oriented programming and the wider Standard Library are beyond the current scope, but you’ll build the foundation they rely on.

Table of Contents

43 lessons · 16 exercises

Getting Started
1
What is C++ and Where It’s UsedⓘUnderstand what C++ is, where industry uses it, and why its performance and hardware control set it apart.
2
Anatomy of a C++ Program: main, Includes, NamespacesⓘUnderstand the structure of every C++ program: the main function, includes, and the std namespace.
3
How a C++ Program is Compiled and RunⓘUnderstand how C++ transforms source code into a running program through the preprocessor, compiler, and linker.
4
Comments, Whitespace, and Code Style BasicsⓘWrite more readable C++ code using comments, whitespace, and indentation to express intent and structure.
Variables and Data Types
5
Variables and declarationsⓘLearn how to declare, initialize, and assign variables in C++, and write readable code with proper naming conventions.
6
Fundamental Types: int, double, char, boolⓘLearn the four core C++ value types, int, double, char, and bool, and what it means for a language to be statically typed.
7
Integer Variants: Size and SignⓘLearn how C++ integer types differ in size and sign, and choose the right one to avoid overflow and subtle bugs.
8
Floating-Point Variants: Precision and SizeⓘLearn how C++ floating-point types differ in precision and when to use float, double, or long double.
9
Literals and constⓘLearn what literals are in C++, how their types are determined, and how to use const to declare unchangeable named values.
10
Type Deduction with autoⓘLearn how C++ uses auto to deduce variable types at compile time, keeping code concise without sacrificing static typing.
11
Checking Type Sizes and Limits in C++ (sizeof, <limits>)ⓘUse sizeof and numeric_limits in C++ to check a type’s exact size and value range on any platform.
12
Type Conversions and Casting in C++ⓘDistinguish implicit widening from narrowing conversions in C++ and cast explicitly with static_cast.
13
Memory, Addresses, and the & OperatorⓘLearn how C++ variables map to memory addresses and how to retrieve one using the & operator.
Operators and Expressions
14
Arithmetic OperatorsⓘLearn how C++ arithmetic operators work, including integer truncation in division, the modulo operator, and operator precedence.
15
Compund Operators and Assignment ExpressionsⓘMaster C++ compound assignment operators and learn how assignment itself is an expression, enabling chained assignments.
16
Comparison and Logical OperatorsⓘMaster C++ comparison and logical operators, understand how they produce bool values, and learn to combine them into precise expressions.
17
Bitwise OperatorsⓘManipulate individual bits in C++ using AND, OR, XOR, NOT, and shift operators with bitset output.
18
Increment and Decrement: Pre vs. PostⓘUse C++’s pre- and post-increment operators correctly and avoid the bugs that come from mixing them.
Input and Output
19
Reading Input with std::cin and std::getlineⓘLearn to read user input in C++ using std::cin and std::getline, and handle the common pitfall of mixing the two.
20
Stream Manipulators and FormattingⓘLearn how to format numbers and text output in C++ using stream manipulators for alignment, decimal places, and padding.
Control Flow
21
Conditional Branching (if, else if, else)ⓘLearn to control program flow in C++ using if, else if, and else branching logic.
22
Switch StatementsⓘLearn how switch statements compare an expression against multiple values in C++, avoiding messy if/else chains.
23
Ternary OperatorⓘWrite single-line conditional expressions in C++ using the ternary operator instead of if/else.
24
The while and do-while LoopsⓘLearn to repeat code with C++’s while and do-while loops, and know when to use each one.
25
Classic for LoopⓘMaster the three-part structure of C++’s for loop, from counting and skipping to variable scope.
26
Loop Flow: break, continue, Nested LoopsⓘControl loop flow in C++ using break and continue, and handle nested loop exits correctly.
Functions
27
Defining and Calling FunctionsⓘLearn to define C++ functions with return types, parameters, and calls that reuse logic across a program.
28
Pass By Value vs. By ReferenceⓘLearn how to pass arguments in C++, by value and by reference, and how each affects your original variable.
29
Default ArgumentsⓘSkip repetitive arguments in C++ functions by assigning default values that callers can override
30
Function OverloadingⓘWrite multiple C++ functions sharing one name, letting the compiler pick the version matching the call.
31
Scope, Lifetime, and Storage DurationⓘLearn how C++ scope, lifetime, and storage duration decide when a variable is visible, alive, and destroyed.
32
Recursion and the Call StackⓘLearn how to write recursive C++ functions, trace their call stack, and convert tail recursion into loops.
Arrays, Strings, and Vectors
33
C-Style ArraysⓘDeclare, loop through, and pass C-style arrays to C++ functions, using sizeof to find array size safely.
34
Multidimensional ArraysⓘLearn how C++ stores and accesses multidimensional arrays using row-major memory layout.
35
C-Style StringsⓘLearn how C++ represents text as null-terminated char arrays and safely use functions like strlen, strcpy, and strcmp.
36
std::string and Its MethodsⓘManipulate, search, and convert text in C++ using std::string’s built-in methods and operators.
37
A Safer, Fixed Array with std::arrayⓘLearn to replace C-style arrays with std::array in C++ for safe indexing, size tracking, comparison, and swapping.
38
A Resizable Container with std::vectorⓘStore, access, and iterate over resizable sequences of elements in C++ using the std::vector container.
Pointers and References
39
Pointer Basics and DereferencingⓘDeclare and dereference C++ pointers to read and modify variables through their memory addresses.
40
Pointer Arithmetic and ArraysⓘLearn how C++ array indexing compiles to pointer arithmetic, and how to traverse arrays using pointers directly.
41
References (Lvalue References)ⓘLearn how C++ references bind to lvalues, enable safe pass-by-reference, and when to choose them over pointers.
42
Null Pointers and nullptrⓘUse C++ nullptr to create, check, and pass null pointers safely, and learn why it replaces NULL and 0.
43
Dangling Pointers and References into a VectorⓘLearn how C++ pointers and references can dangle, including when std::vector grows, and how to fix that case.
Share