Variable is a place holder during program execution. Basically variable are name given to the location in the memory of computer, where different constants are stored. If a program works on some variables then we need to declare these variables with the help of data types.A variable is an entity that may change it value. In any program we typically do lots of calculations. The results of these calculations are stored in computer memory locations. To make the retrieval and usage of these values we give names to the memory locations. These names are called variables.

Naming Variables 

The Variable name can be called identifier. It has to follow some rules:

  • The name can contain letters, digits and underscore but the first letter has to be a letter or the underscore. Avoid underscore as the first letter because it can be clashed with standard system variables.
  • The length of name can be up to 247 characters long.
  • Keywords Cannot be used as a Variable name.
  • The Variable name should be meaningful to the programming context.

Examples of legal variable names include

x          result          outfile          bestyet
x1         x2              out_file         best_yet
power      impetus         gamma            hi_score