- Variable: -
An entity that may vary during program execution is called variable. Variable names are names given to memory location.
In any programs we do a lots of calculations. Using variables we can store, retrieve and manipulate data values.
Syntax: -
Where type is the the type of variable being declared;var-name is the variable name.
For example: -
int x;
float marks;
- No commas or blanks are allowed within a variable name.
- No special symbol other than an underscore (such as in simp_inrst) can be used in a variable name.
Some of useful tips while declaring variables: -
- It is advisable to declare meaningful variable-names. For example, if we want to maintain student database we can use variable names like name, roll_no, marks instead of using datatypes.