Reference languageSubprograms

It is important to read and understand a formal language. Declaring variables and data types, using selection statements, iteration and using operators are comprehensions required before coding.

Part ofComputing ScienceSoftware design and development

Subprograms

Subprograms are either procedures or functions and will usually make use of parameters. The parameters appear within brackets beside the name of the procedure.

Procedure

This is an example of a procedure and includes parameter passing.

PROCEDURE displayResults (INTEGER passmark, INTEGER score, INTEGER grade)
<command to be executed>
<command to be executed>
<command to be executed>
END PROCEDURE

Calling a procedure

In order to call this procedure from the main program the following statement is necessary.

displayResults(passmark, score, grade)

This line of Reference Language would call the procedure for execution and store the result in a variable called finalResult.

SET finalResult TO displayResults(passmark, score, grade)