5.4 — 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 …

4.9 — Boolean values

In real-life, it’s common to ask or be asked questions that can be answered with “yes” or “no”. “Is an apple a fruit?” Yes. “Do you like asparagus?” No. Now consider a similar statement that can be answered with a “true” or “false”: “Apples are a fruit”. It’s clearly true. …

Break Time — Dice Wars

Even though this site is focused on programming, it’s always good to take a break every once in a while. Get up, stretch, and refocus your mind on something else for a few minutes. We all like to have a little bit of fun, and one of the best ways …

4.8 — Floating point numbers

Integers are great for counting whole numbers, but sometimes we need to store very large (positive or negative) numbers, or numbers with a fractional component. A floating point type variable is a variable that can hold a number with a fractional component, such as 4320.0, -3.33, or 0.01226. The floating …