Constants and Variables

Most programs process data in some form or another. A constant is a piece of data that will stay at the same value all the time that the program runs. The length of a room that you use in a game is an example of a constant. If the value of a piece of data changes (or might change) then it is called a variable. The distance of a player from the left wall of a room is an example of a variable.

When you plan a program, you decide on a descriptive name for each piece of data. The name you give to it is its identifier. You use the identifier throughout the program to refer to your piece of data. Readers of your code (including you after some time) will appreciate meaningful identifiers.

This tutorial describes how to use constants and variables in your programs.

Programming - a skill for life!

Pascal Programming Tutorials