Variables in C++ are containers for storing data values. Every variable has a data type that defines the kind of value it can hold, like int
, float
, char
, or string
.
int
or float
, to avoid garbage values.
int
— Integer numbers (e.g. 5, -23, 0)float
— Decimal numbers (e.g. 3.14, -0.5)char
— Single characters (e.g. 'A', 'z')string
— Text strings (e.g. "Hello")bool
— Boolean values (true
or false
)