Fundamental Data Types in C++
C++ builds everything from a small set of fundamental types: int for whole numbers, double for decimals, char for single characters, bool for true/false, and void for nothing (used in function returns). Their exact sizes are platform-dependent — int is at least 16 bits but 32 on virtually every modern system — which is why portable code uses fixed-width aliases like int32_t when exact size matters.
Choosing correctly is mostly about range and intent: double is the default floating type (float exists but halves precision for little gain), char is really a tiny integer that happens to print as a character, and bool makes conditions self-documenting instead of hiding them inside ints.
int: the workhorse
Whole numbers, typically 32 bits (about +-2 billion). The default choice for counts, indexes, and IDs.
double: the default decimal
64-bit floating point with ~15 reliable decimal digits. Prefer it over float unless memory profiling says otherwise.
char: a tiny integer
Usually 8 bits holding a character code. 'A' is just the number 65 in a char-sized slot — arithmetic on chars is legal.
bool and void
bool holds true or false for conditions; void means no value and appears mainly as a function return type.
#include <iostream> int main() { int n = 1000000; double pi = 3.14159; char grade = 'A'; bool passed = true; std::cout << n << ", " << pi << ", " << grade << ", " << passed << std::endl; return 0;}Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in C++ yourself — building beats watching.