Pseudocode Structure Flashcards
Variable assignment
var ← exp
One dimensional array assignment
var[iexp] ← exp
Remember indexing starts at 1 not 0
Two dimensional array assignment
var[iexp1][iexp2] ← exp
Array initialisation of n elements
var ← [exp1, exp2, … , expn]
Conditional (if AND else statements) branching
IF bexp THEN statements ELSE statements ENDIF
Conditional execution (no alternative branching / else)
IF bexp THEN
statements
ENDIF
Multi‐branching conditional with n choices.
CASE exp OF exp1: statements ... expn: statements ELSE statements ENDCASE
Conditional looping with the condition at the start of the loop / while loop
WHILE bexp
statements
ENDWHILE
Remember no colon
Count controlled looping / for loop
FOR var ← iexp1 TO iexp2
statements
ENDFOR
Remember no colon and no ‘in’
Conditional looping with the condition at the end of the loop. The loop must always execute at least once.
REPEAT
statements
UNTIL bexp
raw_input equivalent
USERINPUT
Function definition with n (possibly none) parameters.
FUNCTION fname(param1,…,paramn)
statements
ENDFUNCTION
Remember the statements must include at least one RETURN statement
Procedure definition with n (possibly none) parameters.
PROCEDURE pname(param1,…,paramn)
statements
ENDPROCEDURE
Modulo operator / remainder percentage sign thing
iexp1 MOD iexp2
Function that returns integer value that is length of an array or a string / length of…
LEN (var)