Introduction To Pascal Programming
Introduction To Pascal Programming
PASCAL
PROGRAMMING
LAYOUT OF A PASCAL
PROGRAM
HEADING
DECLARATION
BODY
HEADING
HAS 3 SECTIONS
1) THE WORD PROGRAM
2) NAME OF THE PROGRAM EG.
PROGRAM AREASQUARE
3) THE WORDS INPUTAND OUTPUT IN
BRACKET(Optional)- (INPUT, OUTPUT);
DECLARATION
used to introduce any suitable variables and
constant which will be used later in the
program
Constant- values that do not change during
execution of the program
Variables-values that change during
execution of the program.
types: integer( whole number), real(
decimal numbers), string (text)
Constant Declaration
Note
A reserved word is a word that has a special
meaning to Pascal. (e.g.
Program,If,While,Begin and End)
BODY
This part represents the main program
It must begin with the reserved word BEGIN
and end with the reserved word END.
COMMENTS
If you want to put comments in Pascal, you
place them in curly brackets. { }
Eg. { circumference is pi* diameter}
The computer ignores comments so you can
put anything you want in them. Even if they
aren’t necessarily true.
INPUT STATEMENTS
Input statement format
readln (variablename);
read (variablename);
Eg. Read(length);
Readln(length);
OUTPUT STATEMENTS
format
write(variablename);
writeln(variablename);
writeln(‘comment’);
write(‘comments’,variablename);
Eg.write(area);
Writeln(area);
Writeln(‘area of square is’,area);
ASSIGNMENT STATEMENT
FORMAT
variable:= calculation;