01 · Fundamentals
- variables
- data types
- operators
- std::cout
- std::cin
End of the C++ Course
Congratulations: you have made it through the 4 modules of the C++ Course — from your very first variables and I/O streams to classes and private member encapsulation. Below is a map of everything you have mastered and a three-step final challenge.
Reminder: C++ exercises are verified statically (keywords). To actually run the code, each exercise provides a Compiler Explorer button that copies the code and opens godbolt.org.
Combine what you have learned about C++ by building three small logical components: a boolean checker, an in-place modification using pass-by-reference, and a class that encapsulates a count value.
Write a function that accepts an integer and returns true if it is even, false otherwise. Module 1 (operators) + Module 3 (functions).
Define the function isEven(int n) that returns a boolean value indicating if the passed number is even (n % 2 == 0).
Use the bool return type and the modulo operator (%). Example: return n % 2 == 0;
Solution available after 3 attempts
Write a function that receives a reference to an integer and squares it directly in the original variable. Module 3 (pass-by-reference).
Define the function squareByRef(int& n) that accepts a reference to an integer and calculates its square in-place, modifying the passed variable.
Use void as the return type and int& as the parameter type. Inside the function, write n = n * n;
Solution available after 3 attempts
Create a class that tracks an incrementable numerical value and provides safe methods to access and modify it. Module 4 (classes and constructors).
Add a constructor to the provided Counter class that initializes the private count variable to 0, a public void increment() method that increases count by 1, and a public int getCount() method that returns the current value of count.
Declare the Counter() constructor and the increment() and getCount() methods inside the public section.
Solution available after 3 attempts
A single page with all the essential syntax of modern C++, ready to keep handy while you code.
Consistent practice is the best way to strengthen your skills. Open the C++ Playground to experiment freely with complex scenarios or to prepare your code snippets before testing them on a real compiler.