9.7 — Null pointers

In the previous lesson (), we covered the basics of pointers, which are objects that hold the address of another object. This address can be dereferenced using the dereference operator (*) to get the value at that address: #include <iostream> int main() { int x{ 5 }; std::cout << x; …

2.6 — Why functions are useful, and how to use them effectively

Now that we’ve covered what functions are and some of their basic capabilities, let’s take a closer look at why they’re useful. New programmers often ask, “Can’t we just put all the code inside the main function?” For simple programs, you absolutely can. However, functions provide a number of benefits …

11.13 — For-each loops

In lesson , we showed examples where we used a for loop to iterate through each element of an array. For example: #include <iostream> #include <iterator> // std::size int main() { constexpr int scores[]{ 84, 92, 76, 81, 56 }; constexpr int numStudents{ std::size(scores) }; int maxScore{ 0 }; // …