All guides

A Level Computer Science 9618

Cambridge A Level 9618 pseudocode guide

A strict syntax reference for the A-Level mode of the editor, including user-defined types, array parameters, subroutines, and file access.

Editor workflow
WRITERUNTRACE

Constants, records, and arrays

A-Level constants use =. A previously declared integer constant can be used as an array bound.

pseudocode
TYPE StudentRecord
   DECLARE StudentID : STRING
   DECLARE Score : INTEGER
ENDTYPE

CONSTANT MaxStudents = 100
DECLARE Students : ARRAY[1:MaxStudents] OF StudentRecord

Students[1].StudentID <- "S001"
Students[1].Score <- 84

Array parameters and BYREF

Use BYREF when a procedure must update the caller’s variable or array.

pseudocode
CONSTANT MaxItems = 10

PROCEDURE ClearScores(
   BYREF Scores : ARRAY[1:MaxItems] OF INTEGER
)
   DECLARE Index : INTEGER
   FOR Index <- 1 TO MaxItems
      Scores[Index] <- 0
   NEXT Index
ENDPROCEDURE

Functions and strict typing

Functions declare a return type and must return a compatible value. Conditions must evaluate to BOOLEAN.

pseudocode
FUNCTION CalculateGrade(Score : INTEGER) RETURNS CHAR
   IF Score >= 80 THEN
      RETURN 'A'
   ELSE
      RETURN 'F'
   ENDIF
ENDFUNCTION

OUTPUT CalculateGrade(86)

Text and random files

Text files support sequential reading and writing. Random files use records with SEEK, GETRECORD, and PUTRECORD.

pseudocode
DECLARE Student : StudentRecord
OPENFILE "students.dat" FOR RANDOM
SEEK "students.dat", 1
GETRECORD "students.dat", Student
CLOSEFILE "students.dat"
OUTPUT Student.StudentID

Important differences from IGCSE mode

  • Constants use CONSTANT name = value.
  • WHILE does not use the DO keyword.
  • Procedure calls require CALL.
  • DIV and MOD are infix operators.
  • A-Level string functions include MID, LEFT, and RIGHT.