bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/C++/C++ Tutorial
C++•C++ Tutorial

C++ Data Types

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"; // String

Basic Data Types

The data type specifies the size and type of information the variable will store:

Data TypeSizeDescription
bool1 byteStores true or false values
char1 byteStores a single character/letter/number, or ASCII values
int2 or 4 bytesStores whole numbers, without decimals
float4 bytesStores fractional numbers, containing one or more decimals. Sufficient for storing 6-7 decimal digits
double8 bytesStores 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.

Previous

C++ User Input

Next

C++ Numeric Data Types