Algorithms - EduqasSequence

Algorithms are step-by-step plans for solving problems. They are a starting point when writing a program. Algorithms can be designed using pseudo-code and flowcharts.

Part ofComputer ScienceUnderstanding Computer Science

Sequence

is the first programming construct. In programming, are one after another. Sequence is the order in which the statements are executed.

The sequence of a program is extremely important as carrying out in the wrong order leads to a program performing incorrectly.

An explanation of sequencing, as used in algorithms and programming

In this 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.