ICT Pseudocode
ICT Pseudocode
2. The statements must not have more than one meaning i.e. should be unambiguous
4. A pseudocode should show clearly the start and stop of executable statements and the
control structures (to be discussed later in the section).
5. The input, output and processing statements should be clearly stated, using keywords
such as PRINT, READ, INPUT etc. Below are some examples that demonstrate how to
write a pseudocode
Using pseudocode
Pseudocode can be used to plan out programs. Planning a program that asks people
what the best subject they take is, would look like this in pseudocode:
REPEAT
OUTPUT 'What is the best subject you take?'
INPUT user inputs the best subject they take
STORE the user's input in the answer variable
IF answer = 'Computer Science' THEN
OUTPUT 'Of course it is!'
ELSE
OUTPUT 'Try again!'
UNTIL answer = 'Computer Science'
Example 3.1
Write a pseudocode that can be used to prompt the user to enter two numbers, calculate the sum
and average of the two numbers and then display the output on the screen.
Solution
START
INPUT X, Y
SUM = X + Y
AVERAGE = SUM/2
PRINT SUM
PRINT AVERAGE
STOP
Example 3.2
Write a structured algorithm that would prompt the user to enter the length and width of a
rectangle, calculate the area and perimeter then display the result.
Solution
(i) First draw the rectangle of length (L) and width (W)
(ii) Write down the pseudocode
START
READ L, W
AREA = L * W
PERIMETER = 2(L + W)
PRINT AREA
PRINT PERIMETER
STOP
Example 3.3
Write a pseudocode for a program that can be used to classify people according to age. If a
person is more than 20 years; output “Adult” else output “Young person”
Solution
START
IF AGE> 20 THEN
PRINT “Adult”
ELSE
Unlike a pseudocode which expresses ideas in form of short statements, a flowchart does the
same using both statements and special symbols that have specific meaning. Therefore, a
flowchart is a diagrammatic representation of a program’s algorithm. The symbols are combined
with short text clues which are a form of shorthand understood by programmers. The special
symbols used to draw program flowcharts vary but the most common ones are as outlined below: