Sequence
sequenceIn computer programming, this is a set of instructions that follow on one from another. is the first programming construct. In programming, instructionA single action that can be performed by a computer processor. are executionThe process of a program being run on a computer. one after another. Sequence is the order in which the instructions are executed.
The sequence of instructions is extremely important as carrying out instructions in the wrong order results in a program performing incorrectly.
An explanation of sequencing, as used in algorithms and programming
In this pseudocode Also written as pseudo-code. A method of writing up a set of instructions for a computer program using plain English. This is a good way of planning a program before coding.programSequences of instructions for a computer., designed to find the average of two whole numbers, the instructions are in in the wrong sequence:
SET total TO 0 SET average TO number1/number2 SEND ‘Enter the first number: ‘ TO DISPLAY RECEIVE number1 FROM (INTEGER) KEYBOARD SEND ‘Enter the second number: ‘ TO DISPLAY RECEIVE number2 FROM (INTEGER) KEYBOARD SEND ‘The average is ‘ & average TO DISPLAYRunning this program would result in an error because it tries to calculate the average before it knows the values of the numbers.
This version has the instructions in the correct sequence:
SET total TO 0 SEND ‘Enter the first number: ‘ TO DISPLAY RECEIVE number1 FROM (INTEGER) KEYBOARD SEND ‘Enter the second number: ‘ TO DISPLAY RECEIVE number2 FROM (INTEGER) KEYBOARD SET average TO number1/number2 SEND ‘The average is ‘ & average TO DISPLAYWriting instructions in the wrong order is one of the most common programming errors. It happens no matter which programming languageA language used by a programmer to write a piece of software. is used.