The Foundations of Digital Signal Processing: Theory, Algorithms and Hardware Design

3.3: General Program Structure

3.3 General Program Structure

The minimum syntax of a Pascal program includes a title and a main body (Haigh and Radford, 1984), enclosed within Begin..End delimiters. For instance, the program given in Listing 3.1 would produce the output: Hello World.

Listing 3.1
Program myfirst; Begin   writeln('Hello World'); End. 

All statements must end with a semicolon, with the exception of the statement that immediately precedes an End statement, where it is optional. Groups of statements, or the statements comprising a procedure (method) or function, must be bounded between Begin End delimiters. The semicolon after an End statement is also optional. The final End of a program must terminate with a full stop.

Pascal is a very flexible language having a relaxed format, but it is common protocol to observe certain presentational details. For example, immediately following such reserved words as Begin, Repeat Until, While Do and Case of (which we will examine later), the text should be indented by two spaces. Conversely, the corresponding End statement which signifies the end of a code block should be re-positioned by two spaces to the left. This helps the programmer to follow the logic of the code.

Variables are assigned values using the symbols :=, for example,

a:=b+c; 

This should not be thought of as meaning a is equal to but rather a takes the value of . For instance, the equation a = a

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Barcode Scanners
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.