Pseudocode Structure Flashcards
Variable assignment
var ← exp
One-dimensional array assignment
var[iexp] ← exp
Two-dimensional array assignment
var[iexp1][iexp2] ← exp
What number does indexing start at in Pseudocode?
1
Array initialisation of n elements
var ← [exp1, exp2, … , expn]
Conditional branching
IF bexp THEN statements ELSE statements ENDIF
Conditional execution (no branching)
IF bexp THEN
statements
ENDIF
Multi-branching conditional with n choices
CASE exp OF exp1: statements ... expn: statements ELSE statements ENDCASE
While loop
WHILE bexp
statements
ENDWHILE
For loop
FOR var ← iexp1 TO iexp2
statements
ENDFOR
Repeat/until loop
REPEAT
statements
UNTIL bexp
How many times does each loop run?
While: Zero or more times
For: A specific number of times
Repeat/until: At least once
In a Pseudocode for loop, where does the count variable have scope?
Only within the for loop
One line comment
comment
Function definition with n (possibly no) parameters
FUNCTION fname(param1, … , paramn)
statements
RETURN exp
ENDFUNCTION