Python Variables & Fundamental Data Types
A variable is a named storage container in computer memory (RAM). Because C++ is statically typed, you must declare the exact type of data a variable will hold before using it: integers (int), decimals (double), single characters (char), truths (bool), or text strings (std::string).
"Think of variables as labeled toolboxes. An "int" box is shaped specifically to hold solid integer bricks. You cannot pour milk (double) into the brick box without causing a mess, and you can't put a book (string) in it either!"
Deep Dive: How It Works
int (Integer): Whole numbers without decimals (e.g. 42, -15, 0). Typically 4 bytes (32 bits).
double & float: Floating-point decimal numbers. double gives 64-bit precision (e.g. 3.14159) and is the default for decimals.
char: A single character enclosed in single quotes (e.g. 'A', '$', '9'). 1 byte.
bool: Boolean truth value (true or false). Typically 1 byte.
std::string: Text string enclosed in double quotes (e.g. "ZenCompiler"). Requires #include <string>.
const: Marks a variable as read-only/immutable (e.g. const double PI = 3.14159;).
Syntax Blueprint
int age = 21; // 4 bytes integer double price = 19.99; // 8 bytes decimal char grade = 'A'; // 1 byte character bool isReady = true; // 1 byte boolean std::string user = "Neo";
Syntax: <type> <variable_name> = <initial_value>;
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Using double quotes for a char: char grade = "A";Why it happens: Treating characters like 1-letter strings.
How to fix: Use single quotes for char: char grade = 'A';.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Declare an integer and double
Declare an int variable named fps set to 60.
Declare a double variable named latency set to 1.5.
Print "FPS: 60 | Latency: 1.5ms" using these variables.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.