Pseudocode is a design tool for representing algorithms using a combination of structured English and common symbols. Pseudocode utilises reserved words within algorithms. ## **Pseudocode conventions** Pseudocode blocks must commence with **BEGIN** and conclude with **END**. Reserved words are represented within algorithms using bold text and capitalised. Indentation is used within pseudocode to indicate hierarchy within an algorithm to enhance human readability. Control structures can be nested using appropriate indentation. Values can be assigned to variables using the left-arrow (**<-**) symbol or the **SET** keyword. Values can be input into the algorithm using the **READ** or **INPUT** keywords. Values can be output from the algorithm using the **PRINT**, **RETURN** or **OUTPUT** keywords. Selection control structures are represented in pseudocode using **IF-THEN**, **IF-THEN-ELSE**, **IF-ELSEIF** and **CASE/SWITCH** blocks. Iterative/Repetition control structures are represented using **DO-WHILE**, **REPEAT-UNTIL**, **WHILE** and **FOR** loops. Conditions can be joined using the **AND** and **OR** keywords. Lines may or may not be numbered. ## Array To declare an array in pseudocode we would write ``` TYPE arrayName \[array size] ``` For example: ``` STRING shopping_list[4] ``` STRING is the data type Integer SHOPPING_LIST is the array name \[4] is the array size ## Exam Pseudocode example ``` FUNCTION search (list, low, high, target) WHILE low <= high mid <- (low + high)/2 IF target = list[mid] THEN RETURN mid ELSEIF target > list[mid] THEN low <- mid + 1 ELSE high <- mid - 1 ENDIF ENDWHILE ``` ``` 1 BEGIN 2 IF age is not blank THEN 3 IF age < 18 THEN 4 DISPLAY "Must be 18 or over to apply." 5 RETURN False 6 ELSEIF monthly_income < (rental_price * 3) THEN 7 DISPLAY "Monthly income too low." 8 RETURN False 9 ELSE 10 DISPLAY "Application is valid." 11 RETURN True 12 ENDIF 13 ENDIF 14 END ```