Variables are used to store data, it tell the compiler the nature of the data and compiler reserves the necessary space for it.
Rules to define variables in C++
1. A variable contains only alphanumeric characters(a-z , A-Z , 0-9) and underscore(_).
2. The first character of a variable should start with alphabet(a-z , A-Z) or underscore (_).
3. Variables are also case sensitive.
4. Keep variables name in small alphabets
Syntax – type variable_name;
For Example – int x ,float y
Following example will help you to understand what variables are.
Assume you are writing a program to addition of two numbers. The user has to enter some input for that operands, user needs some memory area to store that two input values, therefore we named that two variables a and b and store in another variable sum so these memory names is known as variables.