sequenceIn computer programming, this is a set of instructions that follow on one from another. is the first programming construct. In programming, statementThe smallest element of a programming language which expresses an action to be carried out. are executeCarry out an instruction. one after another. Sequence is the order in which the statements are executed.
The sequence of a program is extremely important as carrying out instructionA single action that can be performed by a computer processor. in the wrong order leads to 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 the wrong sequence:
total = 0
average = number1/number2
number1 = int(input("Enter the first number: “))
number2 = int(input("Enter the second number: "))
print("The average is ", average)
Running 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:
total = 0
number1 = int(input("Enter the first number: “))
number2 = int(input("Enter the second number: "))
average = number1/number2
print("The average is ", average)
Having instructions in the wrong order is one of the simplest, yet most common, programming errors. It occurs no matter which programming language is used.