0% found this document useful (0 votes)
6 views

ICT Pseudocode

Uploaded by

omar ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

ICT Pseudocode

Uploaded by

omar ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Pseudocode

As mentioned earlier, a pseudocode is a set of statements written in a readable language (usually


English-like phrases) but expressing the processing logic of a program. Some of the words used
in a pseudocode may be drawn directly from a programming language and then mixed with
English to form structured statements that are easily understood by non-programmers and also
make a lot of sense to programmers. However pseudocodes are not executable by a computer.

Guidelines for designing a good pseudocode

1. The statements must be short, clear and readable

2. The statements must not have more than one meaning i.e. should be unambiguous

3. The pseudocode lines should be clearly outlined and indented clearly.

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

PRINT “Enter two numbers”

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

PRINT “Enter length and width”:

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

PRINT “Enter the age” INPUT AGE

IF AGE> 20 THEN

PRINT “Adult”

ELSE

PRINT “Young person”


Program flowcharts

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:

You might also like