A variable is like a container that stores some value and maps it on the memory with a specific name to access it. The variable should be declared before using it. It is a good practice to initialize each variable with a default value to remove garbage.
Pascal provides several intrinsic data types. However, we can derive our own data types as well.
The data types of variables in Pascal are as follows::
The syntax for variable declaration is given below:
varvariable_list : type;
The following example shows how to initialize and declare the variable in Pascal:
program task;var number1 : integer;letter : char;beginnumber1 := 23;letter := 'W';writeln(' ');writeln('****************************');writeln('OUTPUT :number1 = ', number1);writeln(' letter = ', letter);writeln('****************************');end.
number1
and letter
.Note: The following warning will appear:
/usr/bin/ld.bfd: warning: link.res contains output sections; did you forget -T?
It can be ignored. It has been fixed in the development build FPC version 3.1.1 and latest, which have not been released officially.