Rules for Naming Variables

The rules for naming of variables include:
  • You must not use the program name as the name of a variable.

  • You must not use a keyword (reserved word) as the name of a variable.

    Tip: You can test the identifier by typing it in a new line before begin. If it is a keyword (e.g.) message, then it will be emboldened in the editor and must not be used. Remember to delete the word after you have tested it!
  • An identifier must begin with a letter or an underscore "_" and cannot contain spaces.

  • Letters, digits, and underscores are allowed after the first character.

Table 1. Validity of Variable Names
Example Valid? Remarks
NumberOfBoxes Y
number_of_boxes Y
a Y no clear meaning
_Int2 Y
2LittleBirds N not allowed to start with a number
begin N begin is a reserved word
repeat N repeat is a reserved word
box# N invalid character "#"
enough? N invalid character "?"
Programming - a skill for life!

The various types of constants and variables and how to use them