A variable is a name of memory location. It is used to allocate memory to store the given data. Its values can be changed and it can be reused many times. It is a way to represent memory location through symbol so that it can be easily identified.
Declaring a Variable :
Syntax: Datatype variable_list;
Here, a,b,c are variables and int, float and char are datatype.
Initializing a Variable:
Syntax: Datatype variable=value;
Rules To Define Variables:
⦁ A variable can be any alphabet, digit and underscore.
⦁ A variable name should only start with alphabets and underscore but not with digit.
⦁ No spaces are allowed with in the variable name.
⦁ Variable name cannot be any reserved word or keyword. For example:char, float, const, etc.
Valid Variable Names:
Invalid Variable Name:
int a b;