Turbo Pascal 7.0 Guide
Pascal Programs

Program Structure

PROGRAM name;
variable declarations;
BEGIN
   instruction 1;
   instruction 2;
   instruction 3;
END.

Input Instructions

readln(input-list);
readln;

An input list is a single variable name or a series of variable names separated by commas. readln; by itself waits for any key to be pressed before the next line is executed.

Output Instructions

writeln(output-list);
write(output-list);
writeln;

These instructions send the values stored in the output-list to the screen. writeln rather than write causes the cursor to move down to the next line. writeln; by itself moves the cursor to the next line.

Example Program

PROGRAM hello;
VAR name: string[20];
BEGIN
   writeln;
   write('What is your name?');
   readln(name);
   writeln('Hello, ', name, '. Pleased to meet you.');
   readln;
END.

Type in and run the above program.

Exercise

Change the above program to also ask the user where they live. Tell them that this is an excellent place to live (eg Bishop's Stortford is a lovely place to live.)