8.7 — Goto statements

The next kind of control flow statement we’ll cover is the unconditional jump. An unconditional jump causes execution to jump to another spot in the code. The term “unconditional” means the jump always happens (unlike an if-statement or switch-statement, where the jump only happens conditionally based on the result of …

8.5 — Switch statement basics

Although it is possible to chain many if-else-statements together, this is both difficult to read and inefficient. Consider the following program: #include <iostream> void printDigitName(int x) { if (x == 1) std::cout << “One”; else if (x == 2) std::cout << “Two”; else if (x == 3) std::cout << “Three”; …

8.2 — If statements and blocks

The first category of control flow statements we’ll talk about is conditional statements. A is a statement that specifies whether some associated statement(s) should be executed or not. C++ supports two basic kinds of conditionals: if statements (which we introduced in lesson , and will talk about further here) and …

13.7 — Introduction to structs, members, and member selection

There are many instances in programming where we need more than one variable in order to represent something of interest. As we discussed in the introduction to the previous chapter (), a fraction has a numerator and denominator that are linked together into a single mathematical object. Alternatively, lets say …