Sie sind auf Seite 1von 8

Glossary of Programming

Sequence
A control structure where all statements are executed once all in order

Iteration
A control structure in which a group of statements are executed several times
depending on a condition or the number of times it is repeated can be set at the
start of the program. There are three types of iterations; FOR loop, REPEAT UNTIL
loop and WHILE loop.
FOR loop

REPEAT UNTIL
loop

WHILE loop

Set the amount of time it repeats. This is effectively


a count.
Repeats until TRUE
Runs while the value is FALSE
It will run at least once
Checks the condition at the END
Repeats until FALSE
Runs while the value is TRUE
It may not even run
Checks the condition at the START

FOR Loop

REPEAT UNTIL loop

WHILE DO loop

This is an example of a WHILE DO loop. This program will start off from a=10.
The program will only run while the value is under 20. This program keeps
repeating until the value of A becomes 20.

Selection
A control structure in which an option to execute sets of statements and a
condition is used to determine which if (any) structure will be executed. There
are two types of selection structures: IF then ELSE and a CASE structure.

IFTHENELSE

This snippet of code is an example of an IFTHENELSE structure. If the score of


the student inputted is above 90 and less than or equal to 100, then the grade
will be outputted as an A. However, if the score inputted is less than 90, then the
program will instead output the line You did not get an A

CASE

This is an example of CASE in use. Using this control structure allows different
outcomes for different inputs. In this example, the line that is outputted will
depend on the student grade that is inputted. So if A is inputted, then the
program will output Excellent work! However if E is inputted, then the
program will output Trouble ahead!

Using variables
Variables can be used to represent a value. For example x+y is an expression
and x and y are variables. X and y can represent a numerical value, characters,
character strings or memory addresses.

Subroutines
A subroutine is a portion of code within a larger program that performs a specific
task and is relatively independent of the remaining code. It is often coded so that
it can be started (called) several times during the execution of the program. It

will perform that tasks that it is assigned to. Once it has completed its tasks, it
will continue executing the instructions that come after the subroutine. There are
two types of subroutines; PROCEDURE and FUNCTION

Procedures
A procedure is a subroutine that executes its statements when it is called and it
is called when it is said.

This is an example of a procedure in use. The procedure has been named


pause. When pause is called in the program, it will write the line Press any
key when ready and then will wait for the user to input a key press. Once the
user inputs a key, the procedure will then end and the program will continue with
the statements that come after when pause was called.

Functions
A function is a subroutine that returns a single value to the program where it is
called.

This function is being used to compare two numbers and see which one is higher.
If A is bigger than B, then the function will return value A.

Recursion
Recursion is when a function calls on itself.

This is a function called factorial. Inside the function on line 5, you can see it
call factorial again. This is the function calling on itself. The factorial here is
multiplying (n-1) out the bracket.

Das könnte Ihnen auch gefallen