Example: c ← 2πr, c:= 2πr: Mathematical operations
Example: c ← 2πr, c:= 2πr: Mathematical operations
It is written in
symbolic code which must be translated into a programming language before it can be executed.
A statement is defined as an instruction that directs the computer to perform a specific action. In
writing pseudocode, we will refer to singular instructions as statements.
When writing pseudocode, we assume that the order of execution of the statements is from top to
bottom.
Mathematical operations are integral to solution development. They allow us to manipulate the
values we have stored. Here are common mathematical symbols:
Assignment: ← or := Example: c ← 2πr, c := 2πr
Comparison: =, ≠, <, >, ≤, ≥
Arithmetic: +, −, ×, /, mod
Floor/ceiling: ⌊, ⌋, ⌈, ⌉a ← ⌊b⌋ + ⌈c⌉
Logical: and, or
Sums, products: Σ Π Example: h ← Σa∈A 1/a
A keyword is a word that is reserved by a program because the word has a special meaning.
START: This is the start of your pseudocode.
INPUT: This is data retrieved from the user through typing or through an input device.
READ / GET: This is input used when reading data from a data file.
PRINT, DISPLAY, SHOW: This will show your output to a screen or the relevant output device.
COMPUTE, CALCULATE, DETERMINE: This is used to calculate the result of an expression.
SET, INIT: To initialize values
INCREMENT, BUMP: To increase the value of a variable
DECREMENT: To reduce the value of a variable
CONDITION
IF you are happy IF THEN ELSE ENDIF
THEN smile IF THEN ELSE IF ELSE IF ENDIF
ENDIF
Value 3: statement
CASE variable of OTHERS
Value 1: statement Statement
Value 2: statement ENDCASE
ITERATION
FOR every month in a year PRECONDITION: variable X is equal to 1
Compute number of days WHILE Population < Limit
ENDFOR Compute Population as Population +
Births — Deaths
ENDWHILE