Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind C++ Data Types?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___ myNum = 5;3Order
Put the learning moves in the order that makes the concept easiest to apply.
You will learn more about the individual data types in the next chapters.
The data type specifies the size and type of information the variable will store:
As explained in the Variables chapter, a variable in C++ must be a specified data type:
As explained in the Variables chapter, a variable in C++ must be a specified data type:
int myNum = 5;
// Integer (whole number) float myFloatNum = 5.99; // Floating point number double myDoubleNum = 9.98; // Floating point number char myLetter = 'D'; // Character bool myBoolean = true; // Boolean string myText = "Hello"; // StringBasic Data Types
The data type specifies the size and type of information the variable will store:
| Data Type | Size | Description |
|---|---|---|
| bool | 1 byte | Stores true or false values |
| char | 1 byte | Stores a single character/letter/number, or ASCII values |
| int | 2 or 4 bytes | Stores whole numbers, without decimals |
| float | 4 bytes | Stores fractional numbers, containing one or more decimals. Sufficient for storing 6-7 decimal digits |
| double | 8 bytes | Stores fractional numbers, containing one or more decimals. Sufficient for storing 15 decimal digits |
You will learn more about the individual data types in the next chapters.