By changing the conditions and/or some of the data in the program, it is possible to convert a WHILE loop into a REPEAT UNTIL loop that performs the same function.
Infinite loops can be caused by an error in the logic of an algorithm.
They repeat endlessly when a condition in a WHILE loop can never be false.
A similiar situation will occur in a REPEAT UNTIL condition if it can never be true.
Counter-controlled loops are often referred to as FOR loops.
For loops use a variable to determine whether the instructions should be repeated.
Typically used when the number of iterations is known before entering the loop.
Nesting constructs are where there are loops within loops.
They give programmers the flexibility to write complex and powerful algorithms.
Care must be taken as beginnings/ends cannot overlap each other.
Indenting instructions in constructs is a good way of ensuring this.
A subroutine is a portion of code within a larger program.
Also called a procedure, method, function, or routine, it performs a specific task.
When a subroutine is defined, it is given an identifier (name) and some instructions.
Two types of subroutines are procedures and functions...
Comments
No comments have yet been made