Naturally, the variables in Pascal does not instated with zero that may contain garbage values. So it is a superior practice to instate factors in a program. The variables can be instated in their affirmation. The initialization is trailed by the
var
catchphrase as follows.
[c]Age: integer = 23;
Section: char = 'A';
name: string = 'SPlessons';[/c]
In the above example,
integer
and
char
are the data types, Age , Section are the variables. The following is an example description image.
The following is an example which shows the above theory practically.
SPlesson.pas
[c]program SPlesson;
const
ALERT = ' Welcome To SPlessons ';
type
name = string;
var
author, technology: name;
begin
writeln('Please enter author name: ');
readln(author);
writeln('Please enter technology: ');
readln(technology);
writeln;
writeln(ALERT, ' ', author, ' ', technology);
end.[/c]
In the above example,
writeln
is used to print the statement that 'Please enter author name ' and 'Please enter technology'. The
readln
is used to read the enterd technology.
Output: Now compile the code result will be as follows.
[c]
Please enter author name: Sam
Please enter technology: JAVA
Welcome To SPlessons Sam JAVA[/c]