麻豆官网首页入口

Pseudo-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.

Diagram showing the three categories most processes fall into, inputs, processes and outputs

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 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

Table with common flow diagram symbols, their names and their usage