A brief note on Procedures, Functions and Strings . Read it before a test. Try each question at the end before you open its answer.
Subroutines Procedure: PROCEDURE Name(Param : TYPE) ... ENDPROCEDURE. Run it with CALL Name(value). Function: FUNCTION Name(Param : TYPE) RETURNS TYPE ... RETURN value ... ENDFUNCTION. Use it inside an expression, never with CALL. Parameters: at most three, each with a data type. Arguments match them in order. Local variable: declared inside a subroutine, used only there. Global variable: declared in the main program, used anywhere. Subroutines are defined at the start of the code. Library routines DIV(A, B): the whole part. MOD(A, B): the remainder. ROUND(Value, Places): rounds to that many decimal places. RANDOM(): a number from 0 to 1, both included. ROUND(RANDOM() * 6, 0) is a whole number from 0 to 6. Strings LENGTH(Text): the number of characters, spaces included. SUBSTRING(Text, Start, Length): usually position 1 is the first character. UCASE and LCASE: upper and lower case. A loop over a string: FOR I ← 1 TO LENGTH(Text) with SUBSTRING(Text, I, 1). Maintainable programs Meaningful identifiers, comments, constants and subroutines. In the 15-mark scenario: list the tasks, plan the data, write in commented parts, dry-run it. Practice with new numbers
A program to try The program defines a function that counts the words of a sentence by counting its spaces, the way a pseudocode loop with SUBSTRING would.
Read it first. Then run it. Is the word count right?
1. Put two spaces between two words. What goes wrong, and how could you check for it?
Mistakes to avoid CALL with a function, or a function with no RETURN. A local variable used outside its subroutine. Counting string positions from 0 when the question uses 1. Forgetting the spaces in LENGTH. Magic numbers where a constant belongs. Check yourself What does SUBSTRING("Rainbow", 5, 3) return? Stuck? Show a hint Show the answerCan a procedure return a value? Stuck? Show a hint Show the answerWhat does ROUND(9.96, 1) return? Stuck? Show a hint Show the answerWrite a statement that outputs the first character of City in lower case. Stuck? Show a hint Show the answerWhy use a local variable for a loop counter inside a procedure? Stuck? Show a hint Show the answerSources Cambridge International, IGCSE Computer Science 0478 syllabus for 2026 to 2028, unit 8.1 and section 4 (pseudocode).