Programming terms
Introduction
There are a number of terms associated with procedural languages that you should know about.
Statement
A programming statement is a self-contained element in a programming language. Some statements make use of single keywords, such as 'writeln' or 'input'. Sometimes, a statement makes use of a compound statement, such as IF <cond> THEN DO xxxx ELSE xxxx ENDIF.
Subroutine
A subroutine is a self-contained block of code. It usually performs one job. Subroutines are written so that they can be reused - you don't have to write the same code again to carry out the same function. You just call the subroutine again. This means smaller and faster programs, which are easier to understand. The term 'subroutine' is often used interchangeably in books and other sources with words like 'module', 'function' and 'procedure'.
Procedure
See subroutine above. A procedure is a self-contained block of code that usually performs one job. To work, you often need to pass to the procedure some data, the data will be worked on, and then some data may be passed out of the procedure and back into the main program. This isn't always the case, however!
Function
See subroutine and procedure above. The key difference between a function and a procedure is that a function will always pass back one and only one piece of data as a result of whatever calculations are done by the function. The data is passed back using a variable, which has the same name as the function itself.
Parameter
Parameters are the specifications of the pieces of data that a function or procedure expects to receive before the function or procedure can actually run. If the function or procedure doesn't receive the correct pieces of data then an error occurs and the program will stop.
Argument
An argument is an actual piece of data. For example, you pass an argument to a parameter in a function call.
Sequence
This is discussed in 3.2.2.
Selection
This is discussed in 3.2.2.
Iteration / Repetition
This is discussed in 3.2.2.
Loop
This terms describes when the same code is repeated a number of times - it loops around itself. You will find loops in iterative constructs in all procedural languages. You can see some examples of loops 3.2.2d.