Data types

In most programming languages, it is necessary to let the computer know the type of data that will be held in a variable.

Integer and String are two very common data types.

  • Integer (whole numbers) - eg 12, -3839, 100,000
  • String (characters) - eg names, postcodes

In reference language you can declare a variable and its data type as follows:

DECLARE score AS INTEGER

This would create a variable called score. The computer would now know that whole numbers (integers) can be stored within the score variable.

If you asked for someone's test mark (integer) and they typed in their name (string) the programming language would find an error. This is because it is only possible to store whole numbers using the INTEGER data type.