pseudocode Flashcards
if statement
IF, THEN, ENDIF
case
CASE, OF, OTHERWISE, ENDCASE
for loop
FOR, TO, NEXT
repeat loop
REPEAT
UNTIL
while loop
WHILE, DO, ENDWHILE
algorithm
sets out steps to complete a given task
types of algorithm
totalling, counting, finding max min and average, linear search, bubble sort
constant
unchangeable variable
eg.CONSTANT hourlyrate <- 6.5
arrays
stores elements of same data type
declare 1d array
DECLARE cars: ARRAY [1:7] OF STRING
DECLARE 2D ARRAY
DECLARE cars: ARRAY [1:7, 1:2] OF INTEGER
storing 1d array
cars[1] <- “dodge”
storing 2d array
cars [1,2] <- 2
string operation finding length
finds number of characters in a string
LENGTH(“days”)
or
LENGTH(days)
string operation turning into lower case
LCASE(“days”)
or
LCASE(days)
string operation turning upper case
UCASE(“days”)
or
UCASE(days)
string operation printing part of a word
SUBSTRING (“happy days”, 1, 5)
1- first character till fifth
rounding an integer
ROUND(10.6, 1)
rounds 10.6 to one decimal place
random
random outputs any number between 1 and 0 inclusive
RANDOM()
what happens when a function is called in the middle of the program
A call statement is used in order to make use of a function
Parameters are / may be passed (from the main program) to the function
function performs its task
and returns a value
calling procedures without perameters
PROCEDURE password()
INPUT password1
OUTPUT password1
ENDPROCEDURE
CALLpassword()
calling proceudres with perameters
PROCEDURE operation (num1:INTEGER, num2:INTEGER)
DECLARE resukt
result<- numb1+numb2
OUTPUT result
CALL operation(2,3)
calling function without perameter
FUNCTION cars RETURNS STRING
INPUT car
RETURN car
ENDFUNCTION
OUTPUT (cars)
calling function with perameter
FUNCTION operation (numb1: INTEGER) RETURNS INTEGER
DECLARE calculation
calculation <- numb1 *numb1
RETURN calculation
ENDFUNCTION
OUTPUT (operation(5))