Pseudocode Notes
Pseudocode Notes
NARRATIVE CODE –
NARRATIVE CODE: (resembles sentences, cannot be understood by a
computer)
Write a program to read three numbers and display the sum.
Start
Get three numbers
Add the numbers
Store the result in a sum
Display the sum
End
PSEUDOCODE
Uses shorter variable names
Uses the shortest method to complete a task
1|Page
PSEUDOCODE TERMS / KEYWORDS
INPUT TERMS: INPUT, READ, GET
OUTPUT: WRITE, DISPLAY, PRINT
TO SET A VALUE: STORE, , =
OTHER CONSTRUCTS:
IF, ELSE, ELSEIF
FOR
WHILE, REPEAT UNTIL
ALL COMPUTER PROCESSSES BOIL DOWN TO 10101010 (ones and
zeros)
VARIABLES:
A variable is assigned a position in memory. Some variables may have to be
initialised. Variables are values that can changed.
Examples of the use of variables: number 1 n1, number 2 n2.
MATHEMATICAL OPERATORS:
+ ADDITION
- SUBTRACTION
* MULTIPLICATION
/ DIVISION
RELATIONAL OPERATORS:
> GREATER THAN
< LESS THAN
>= GREATER THAN OR EQUAL
TO
<= LESS THAN OR EQUAL TO
!= or NOT EQUAL TO
<>
2|Page
DATA TYPES:
INTEGERS – whole numbers that can be positive or negative. Eg. 77, -90,234
FLOATING POINT NUMBERS OR REAL NUMBERS. They can be positive
or negative but always have a decimal point. Eg 3.45, 0.45, -0.21
CHARACTERS – anything that can be entered from a keyboard. (&, #, g, 7, *)
PSEUDOCODE examples.
Write a program to read 3 numbers and display the sum
Answer:
Start
Read a (can be substituted for input, get)
Read b
Read c
Sum = a+b+c
Display sum
Stop
Example 2.
Read 3 numbers, find the average of the 3 numbers and multiply the average by
the sum of the 3 numbers.
Start
Read a
Read b
Read c
Sum = a+b+c
Avg = sum/3
Answer = avg * sum
Print answer
Stop
3|Page
Area = l * w
Print area
4|Page