Sie sind auf Seite 1von 19

INTRODUCTION TO

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

 This section starts with the word CONST.


Eg.
CONST
Pi=3.142;
GCT=16.5;

Notice the following difference;


1.You can and must specify a value
2.You use = instead of ;
3. You don’t have to specify a type. The computer will
look at the value and figure out a type.
Variable Declaration
 The same programming rules apply for
naming variables and the data it can hold.

 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;

Eg. Area:= length * width;

N.B. – At the end of each statement there


should be a semi-colon.
Recap

 What are the main parts of a Pascal


program?
 What are the three parts of the heading?
 What is the declaration in a Pascal program
used for?
 What are the different data types used in the
declaration?
 What key words are used to start and
terminate the body of a program?
POINTS TO NOTE!!!!
 After the creation of any Pascal program it
must be :
compiled
run
save
 Write a pascal program to say HELLO
WORLD!
DEV PASCAL
In curly brackets above the program write your
name, date and purpose of the program.

Name: Christopher Pharrell


Date: June 10, 2018
Purpose : to find the sum of two numbers
COMPILING
SUCCESSFUL COMPILATION
RUNNING
SUCCESSFUL RUNNING
LET US NOW
ENTER INTO THE
DEV PASCAL
ENVIRONMENT !!!!

Das könnte Ihnen auch gefallen