Skip to main content

Flowchart and Pseudocode

Flowcharts

To be able to create a meaningful flowchart, an algorithm must first be created. Algorithm can be developed into Pseudocode. This takes each step and revises them into a from called structured.

The Step-by-step instructions used to solve a problem can be used to create a diagram which is called Flowchart. It uses symbol to represent the different types of instructions. The flowchart symblos are linked togheter with arrows showing the direction of flow.


Pseudocode

The algorithm can then be taken and be changed into pseudocode. This is fake programming language.

It does not hvae any computing commands. It helps you to think through the problem and ensure that the solution work.

Before pseudocode can be written some basic programming concepts need to be understood.

CommandDescription
Variablestorage mechanism where the data can change be updated for example results of calculation
Constantsstorage mechanism where data that does not change through the running of a program
Key processesif statements, calculations
Repeated processloops used to repeat specific parts of a program
Inputsthese are inputs into the program, this can be from the keyboard or mouse, etc...
Outputsthese are outputs to the screen

Pseudocode must be laid out in a particular way. The code must be indented. This means that it must be tabbed across the page.

Think of indentation as a replacement for brackets like in math's. It means one set code is related to the outer set.

Example 1

BEGIN
SET age
INPUT age
IF age is greater than 17
DISPLAY you can vote.
ELSE
DISPLAY you cannot vote.
SET vote
END IF
END

Example 2

{
SET age​
INPUT age​
IF age is greater than 17
DISPLAY you can vote.
ELSE
DISPLAY you cannot vote.
SET Vote​
}

Which is easier to read?

  • Example-1
  • Example-2

How to Write Pseudocode

CommandExecuteDescription
Start/EndBEGIN and ENDUsed to show the start of the program and the end of the program
InputINPUT, READ or OBTAINThis is anything entered into the program
OutputsPRINT or DISPLAYThis is to display something to the user or send something to the printer​
Processes CALCULATE, SUM or GENERATEThis is carries out an action or task
Variables SET or INITIALISEInitialise a variable to be used to store data or update the data
Loop/IterationWHILE
REPEAT - UNTIL
a loop (iteration that has a condition at the beginning)​
a loop (iteration) that has a condition at the end​
Decision/Conditional IF - THEN - ELSEa decision (selection) in which a choice is made​ any instructions that occur inside a selection or iteration are usually indented​

Repeats

Repeat is a command that create a repetiontion for a spcific block of code. This is called "for loop"

{
REPEAT
DISPLAY Insert card
INPUT card details
SET card details
IF card is invalid
card not accepted
ELSE
card is accepted
UNTIL card is accepted
SET oddNumbers to 0
FOR count = 1 to 10
DISPLAY count
SET count + 2
END FOR
}

IF

These use a condition to make a decision

{
IF card is invalid
card not accepted
ELSE
card is accepted
}