Вы находитесь на странице: 1из 2

Algorithm Representation

Symbol Usage

Terminal – Begin / End

Begin / End There should only be one Begin and one End in the
algorithm. Subprograms have their own Begin and End.

Process Process – initialisation (setting start-up values); assignment


(setting values) or calculation

Input / Output
Input / Output

Decision: selection or repetition


This symbol is used to show any condition that is tested.

There are two types of selection: binary and multi-way.


Binary selection can be expanded to multi-way through
Decision nested IF statements. However, CASE statements are a
more efficient way of coding multiple paths.

There are two types of repetition: guarded / pre-test or


unguarded/ post-test. Guarded loops test the condition
before executing the statements within the loop. Unguarded
loops test the condition after executing the statements within
the loop once.

WHILE loops must be primed – the variable(s) tested in the


condition must be set prior to the beginning of the loop.

Fixed iteration loops are a form of guarded loops which run


a set number of times (although this can be determined by
the value of variables). They are useful because the
incrementation of the condition value is automatic.

The variables that are tested in the condition must be


updated in the loop. If the value doesn't change the loop
will continue forming an infinite loop.

Subprogram – a subprogram is a section of code that can be


reused any number of times during the program. Variables
can be passed into subprograms in the form of arguments /
Subprogram
parameters to allow for minor changes in the running of the
subprogram.

Subprograms are procedures or functions and can be created


by the programmer or preexisting.
Usage Pseudocode

Terminal – Begin / End


Begin
There should only be one Begin and one End in the End
algorithm. Subprograms have their own Begin and
End.

Process – initialisation (setting start-up values); Variable = X


assignment (setting values) or calculation Set VariableName to X

Input / Output Get value / Accept value


Display value / Print value

Decision: selection or repetition Binary selection:


This symbol is used to show any condition that is IF (condition) THEN
tested. statements
ELSE
There are two types of selection: binary and multi- statements
way. Binary selection can be expanded to multi-way ENDIF
through nested IF statements. However, CASE
statements are a more efficient way of coding Multi-way selection:
multiple paths. CASEWHERE expression is
value : statements
There are two types of repetition: guarded / pre-test or value : statements
unguarded/ post-test. Guarded loops test the OTHERWISE : statements
condition before executing the statements within the ENDCASE
loop. Unguarded loops test the condition after
executing the statements within the loop once. Guarded loops:
WHILE condition
WHILE loops must be primed – the variable(s) tested statements
in the condition must be set prior to the beginning of ENDWHILE
the loop.
FOR (a fixed number of iterations)
Fixed iteration loops are a form of guarded loops statements
which run a set number of times (although this can be ENDFOR
determined by the value of variables). They are
useful because the incrementation of the condition Unguarded loops:
value is automatic. REPEAT
statements
The variables that are tested in the condition must be UNTIL condition
updated in the loop. If the value doesn't change the
loop will continue forming an infinite loop.

Subprogram – a subprogram is a section of code that SubprogramName (Parameters)


can be reused any number of times during the
program. Variables can be passed into subprograms in (Note: in pseudocode, subprograms are
the form of arguments / parameters to allow for minor simply represented by underlining the name
changes in the running of the subprogram. of the subprogram.)

Subprograms are procedures or functions and can be


created by the programmer or preexisting.

Вам также может понравиться