Reference
Data Types
| Data Type | Size | Description |
|---|---|---|
bool | 1 byte | Stores true or false values |
char | 1 byte | Stores a single character/letter/number, or ASCII values. The character must be surrounded by single quotes |
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 |
string | varies | Stores a sequence of characters (text). This is not a built-in type, but it behaves like one in its most basic usage. String values must be surrounded by double quotes. A string in C++ is actually an object, which contain functions that can perform certain operations on strings. For example, you can also concatenate strings with the append() function. For examples: text.append(“hello”), text.length(). |
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
