Algorithms:
Pseudo Code
3
Engage
What is the differences between the two codes below?
2
Pseudo Code
Learning Objective:
Understand the use of pseudo code and how to write it.
Learning outcome:
To be able to read and write pseudo code for a particular problem.
3
iCan()
iCan.Explore()
I show an understanding of the topic by briefly describing my understanding
iCan.Enhance()
I show a good technical understanding and am able to show this through detailed description and evaluation of effectiveness.
iCan.Excel()
I can show an excellent technical understanding of the topic and can give factually correct examples and evidence.
4
Pseudo code
Pseudocode is a style of algorithm writing that should be adaptable to any program language. There are not set rules for how to write pseudocode but it should be readable by any programmer.
What are the benefits of pseudo code?
5
INPUT is sugar required
IF (sugar is required)
THEN OUTPUT add sugar
ELSE
OUTPUT don’t add sugar
ENDIF
Writing Pseudo code
6
INPUT is sugar required
IF (sugar is required)
THEN OUTPUT add sugar
ELSE
OUTPUT don’t add sugar
ENDIF
Benefits of Pseudo code
7
INPUT is sugar required
IF (sugar is required)
THEN OUTPUT add sugar
ELSE
OUTPUT don’t add sugar
ENDIF
Loops
8
WHILE answer != “computer”
answer = INPUT what is the password
ENDWHILE
FOR i=0 to 7
OUTPUT “hello”
i++ #increase i by 1
ENDFOR
The image shows an example of a FOR LOOP and a WHILE LOOP.
The big difference to note is we first must declare the end of the loop.
Secondly we must manually increase values such as i as not all program languages does this step for us.