
Variables are similar to constants, but their values can be changed as the program runs. Unlike in BASIC and other loosely-typed languages, variables must be declared in Pascal before they can be used:
var
IdentifierList1 : DataType1;
IdentifierList2 : DataType2;
IdentifierList3 : DataType3;
...
IdentifierList is a series of identifiers, separated by commas
(,). All identifiers in the list are declared as being
of the same data type.
The main data types in Pascal are:
integer
real
char
Boolean
Note that although constants may be strings, there is no built-in
type called string except in some specialized
implementations (such as Turbo Pascal).
More information on Pascal data types:
var
age, year, grade : integer;
circumference : real;
LetterGrade : char;
DidYouFail : Boolean;
Previous lesson |
Next lesson |
Contents |
Index |
e-mail me |