High-level Programming Language (Pascal)
Introduction
Pascal is the high-level programming language that use English-like statements to instruct the computer how to complete the specific task. Programming is the task of preparing the instructions and data required to enable a computer to undertake a particular job.
General Structure of a Pascal Program
|
Major
parts of a Pascal program
|
Example
|
|
|
I
|
Program heading | program ProgramName ; |
|
II
|
Declaration part | const type { not covered in HKCEE syllabus } var procedure function { not covered in HKCEE syllabus } |
|
III
|
Program body | begin ¡@statement_1 ; ¡@statement_2 ; ¡@¡@¡@¡@... ¡@¡@¡@¡@... ¡@statement_n end. |
program ProgramName ;
const ¡@Pi = 3.14159 ; ¡@¡@{real constant}
¡@¡@¡@¡@Year = 2000 ; ¡@¡@ {integer constant}
¡@¡@¡@¡@Male = 'M' ; ¡@¡@¡@ {char constant}
¡@¡@¡@¡@MyName = 'Peter'; {string constant}
¡@¡@¡@¡@Found = true ; ¡@¡@{boolean constant}
var ¡@Year : integer ; ¡@¡@¡@¡@ {integer variable}
¡@¡@¡@Salary, Price : real ; ¡@¡@{real variables}
¡@¡@¡@MyName : string[30] ;¡@ {string variable}
¡@¡@¡@Address : string;¡@ ¡@¡@¡@{string variable}
¡@¡@¡@Found : boolean ; ¡@¡@¡@ {boolean variable}
begin
¡@writeln ('Hello !') ;
¡@writeln ('How are you ?')
end.