Programming Pascal 1 - Structure
 

A format of very simple Pascal programs :

uses ....

var
...

begin
.... (Your program is here)
end.


The word end here should end with stop ('.').



Every Pascal program blocks begins with the word begin and ends with the word end.


Some of the end word ends with semicolon ';' or period '.' or just nothing.

For example :

begin
  Writeln('Hello, World !');
end.


In this case we don't need the word uses and var. Try to run it.
It should display 'Hello, World !' on screen. But perhaps it's too fast.
 


What is the word uses for ?
It's a kind of terms to declare that we use specific library.
Some are standard ones.
At first, we use the standard ones that come with every Pascal compiler.
The one we will use most is crt unit, which contains various commands that are frequently used.


What is Writeln for ?
Writeln
is a command to write something into the screen. If you want to write a sentence, just wrap it with quote ('). And don't forget the pair of brackets and the semicolon. Example :



begin
Writeln('I learn Pascal');
Writeln('Hi, there !');
end.

To clear the screen when the program starts.
You need to add the word Clrscr; just after the word begin.
Clrscr is one of the commands included in crt library.(Unit)



uses crt;

begin
Clrscr;
Writeln('I learn Pascal');
Writeln('Hi, there !');
end.




Pascal has a command Write instead of Writeln.
Try  replacing all the Writeln into Write and Run it and see what happens. See the difference ?

It'll output I learn PascalHi, there !. Stick ! 

I learn Pascal

Hi, there !

(c) Shilpa Sayura Foundation 2006-2017