Naming Variables and Constants

Hours Worked Box

Every programming language has its own rules about how variables and constants are named. The word used to describe the name given to a variable or a constant is its identifier. In the example shown in the picture the identifier name is HoursWorked.

Some common rules state that variable identifier names:

  • Must not contain any spaces, therefore, bank_balance and BankBalance are acceptable but bank balance or Bank Balance are not.
  • Must start with a letter or underscore character.
  • Can contain a mixture of letters, digits and other special characters after the first character.

Next: Data Types Quiz