Pseudocode
- Pseudocode is a way of writing an algorithm that looks like code but is not a real programming language. It lets you plan without worrying about exact syntax.
- Exam boards use their own styles: AQA has its own pseudocode, OCR uses its Exam Reference Language, and Edexcel uses Python. You can usually answer in pseudocode or in a high-level language such as Python, as long as your steps are clear.
Flowchart symbols
- Terminal (rounded rectangle): start and stop. Input/output (parallelogram). Process (rectangle): an action or calculation.
- Decision (diamond): a question with two exits, Yes and No. Subroutine (rectangle with double lines at the sides): a call to another part of the program.
- Arrows (flow lines) show the order. An arrow going back to an earlier step makes a loop.
Reading an algorithm
- Work through it one step at a time and keep track of every variable, for example in a trace table.
- An algorithm sets count to 0. While count is less than 3, it outputs count and adds 1. It outputs 0, 1 and 2, then stops because count is 3.
Writing clear algorithms
- Use meaningful variable names, indent the code inside loops and IF statements, and add comments to explain tricky parts.
Key terms
- Pseudocode
- A way of writing an algorithm that looks like code but isn't a real programming language.
- Flowchart
- A diagram that shows the steps of an algorithm using standard symbols.
- Terminal
- The rounded rectangle that shows the start or end of a flowchart.
- Process
- The rectangle used for an action or calculation.
- Decision
- The diamond used for a question with Yes and No exits.
- Input/output
- The parallelogram used when data goes in or comes out.