In C++, variables are containers for storing data values. To use a variable, you must declare its type and name, and optionally, initialize it with a value. Here’s how it’s done:
// Declaration without initialization
int age;
float height;
// Declaration with initialization
double pi = 3.14159;
char grade = ‘A’;
In the above examples, int, float, double, and char are data types, while age, height, pi, and grade are variable names. The equals sign (=) is used for initialization, where the value on the right is assigned to the variable on the left.