Pascal Program Structure

Structure of a Pascal program consists of a title of program (program heading) and a block of programs (program block) or agency program (body program). Block program is divided into two parts, namely the declaration (declaration part) and the statement (statement part). The declaration section can contain the declaration of labels (labels declaration), the declaration of constants (constants declaration), the declaration of the type (type declaration), the declaration of variables (variables declaration), the declaration procedure (declaration procedures) and the function declarations (function declaration). In summary, the structure of a Pascal program can consist of:

1. Program Title
2. Block Program
a. Declaration Section
Declaration label
Constant declaration
Declaration type
Variable Declaration
Declaration procedure
Function declaration
b. Part Statement

Pascal programs are the most simple

A Pascal program is the simplest program that only consists of a statement of course. Part of the statement (statement part) is the last part of a block. This section begins with the reserved word BEGIN and end with a reserved word End. Thus a Pascal program can simplest form:

Begin
End.

Block statements must be preceded by the words Begin and end with the word End of a point behind (End.). Do not forget ya! While the general format for a program usually is:

Program ...
Uses ...

Var
... ...
Begin
... Statements ...
End.

Said the program should exist, may not (optional). Useless to give only program's name. Then try to type the following statement and then run it (Ctrl F9):

Begin
writeln ( 'Hello World! ");
End.

In this case we do not use the uses and var. Above program should result in the word 'Hello' on the screen. If too fast, press the F5 alt. Then press any key to return to the editor Pascal.



Uses

To what uses it? Uses are similar term that means we use a library (libraries) specific. So now, whether the library is? To more easily, let's just kind of library had a box in which there are the commands we need for our program later on, like clrscr, readkey, keypressed, readln, etc..
Question again, why the program did not use the above uses? Because the writeln statement is using TP's standard library (system unit), which need not be written again.

Oh, yes. Incase Pascal language-sensitive nature, which means ignoring the large or small letters. So it's up to write the word begin or Begin with the BEGIN or even begin. No matter koq. And do not forget, in general, at the end of a command always ends with a semicolon (;).



Use Write and WriteLn

Syntax write: write ( '');
Syntax writeln: writeln ( '');
For more details, type the following commands into your Pascal editor and then run it (Ctrl F9).

Uses crt;
begin
clrscr;
writeln ( 'This first line');
writeln ( 'This second line');
write ( 'This third line');
write ( 'This appears beside');
writeln;
write ( 'This fourth line');
end.

Already know what purpose and what's the difference? To be sure, just write command to write it while the writeln command to write and move the cursor to the next line.
0 Komentar untuk "Pascal Program Structure"

Back To Top