# Representing algorithms

An is a set of instructions that describes how to solve a problem. Algorithms can be designed using and/or . They are written using and expressions.

Whether algorithms are designed with pseudo-code or flowcharts, the focus is on the logic of the steps instead of the because programmers should be able to translate an algorithm into any programming language, for example, from Python to C++. This is known as being .

This video is from the series ‘How to Think like a Computer’ on BBC Teach’

## Psuedo-code

Pseudo-code is a simple way of describing a set of instructions in a manner that resembles a programming language. In an algorithm, most processes fall into three main categories:

When pseudo-code is being written, inputs, processes and outputs can be identified using the key words in the code.

For example, if a person was writing a program where a number is input and the program calculates and outputs the times table up to ten, they could write a statement like this:

 The user INPUTS a number which is saved as num FOR each number from 1 to 10, OUTPUT num*number 

This could be improved by writing the pseudocode:

 num ← USERINPUT FOR number ← 1 TO 10 OUTPUT number * num ENDFOR 

The ← symbol in pseudo-code means . Most programming languages use = instead of ←. In the example above, num ← USERINPUT means that the user input is being put into, or assigned to, the called num.

Outputs use the word OUTPUT before the to be sent to the user. In the example above, the line OUTPUT number * num in Python might look like print (number * num).

Processing refers to any operation the computer system is performing on data, for example doing a calculation or searching for something. In OUTPUT number * num, the program is actually performing a calculation within the output, so it is possible to see statements which combine one or more of these.

## Flowcharts

A flowchart is a diagram that shows an overview of an algorithm. Flowcharts use a variety of standard symbols to represent different elements, and arrows to show the flow or direction. These symbols are used to construct the flowchart and show the step-by-step solution to the problem.

Common flow diagram symbols