6.7 — Logical operators

While relational (comparison) operators can be used to test whether a particular condition is true or false, they can only test one condition at a time. Often we need to know whether multiple conditions are true simultaneously. For example, to check whether we’ve won the lottery, we have to compare …

6.5 — The comma operator

The allows you to evaluate multiple expressions wherever a single expression is allowed. The comma operator evaluates the left operand, then the right operand, and then returns the result of the right operand. For example: #include <iostream> int main() { int x{ 1 }; int y{ 2 }; std::cout << …

5.2 — Literals

are values that are inserted directly into the code. For example: return 5; // 5 is an integer literal bool myNameIsAlex { true }; // true is a boolean literal double d { 3.4 }; // 3.4 is a double literal std::cout << “Hello, world!”; // “Hello, world!” is a …

4.11 — Chars

To this point, the fundamental data types we’ve looked at have been used to hold numbers (integers and floating points) or true/false values (Booleans). But what if we want to store letters or punctuation? #include <iostream> int main() { std::cout << “Would you like a burrito? (y/n)”; // We want …