A program that always displays the same message can get a bit boring. Most programs get some information, do some calculations, and then display the results of the calculations.

Information is stored in memory as variables. Variables can vary, or change. Before a variable can be used, it must be declared. To declare a variable, first decide what type of information you want to store:

  • Whole numbers, number with no decimal places are called integers.
  • Numbers with decimal places are called double.
  • Single letters such as ‘Y’ or ‘N’ are characters.
  • A variable that can only have the values true and false is bool (Boolean).
  • Words, such as "Hello", or a person's name are strings. Strings are somewhat more complicated because they require an array of memory locations. Strings are discussed in another chapter.

NEXT: Drill on type