Computer science

Subdecks (1)

Cards (875)

  • Contents
    • Introduction
    • How should teachers use this guide?
    • Pseudocode in examined components
    • Font style and size
    • Indentation
    • Case and italics
    • Lines and numbering
    • Comments
    • Variables, constants and data types
    • Atomic type names
    • Literals
    • Identifiers
    • Assignments
    • Arrays
    • Declaring arrays
    • Using arrays
    • Common operations
    • Input and output
    • Arithmetic operations
    • Logic operators
    • Selection
    • IF statements
    • CASE statements
    • Iteration
    • Count-controlled (FOR) loops
    • Post-condition (REPEAT UNTIL) loops
  • Cambridge International Examinations retains the copyright on all its publications
  • Registered Centres are permitted to copy material from this booklet for their own internal use
  • Centres cannot photocopy material acknowledged to a third party even for internal use within a Centre
  • Version 2
  • Types of loops
    • Count-controlled (FOR) loops
    • Post-condition (REPEAT UNTIL) loops
    • Pre-condition (WHILE) loops
  • Index of symbols and keywords
    • Font style and size
    • Indentation
    • Case and italics
    • Lines and numbering
  • Teachers should follow the guide in their teaching to help learners understand pseudocode presented in examination papers and pre-release materials more easily
  • Using a recommended style in pseudocode will enable candidates to communicate their solutions more effectively to the Examiner
  • Learners are not required to follow the guide in their examination answers or any other material presented for assessment
  • Pseudocode is not a programming language with a defined, mandatory syntax
  • Candidates will be given credit for pseudocode based on the logic of the solution presented
  • Pseudocode will be presented in a monospaced (fixed-width) font such as Courier New with consistent font size
  • Lines in pseudocode are indented by four spaces, with continuation lines indented by two spaces if needed
  • Keywords in pseudocode are in uppercase, identifiers are in mixed case, and meta-variables are enclosed in angled brackets
  • Descriptions in pseudocode are written in italics
  • Line numbers in pseudocode are presented to the left with sufficient space to indicate they are not part of the statements
  • Line numbers are consecutive unless skipped to indicate missing code
  • Each line representing a statement in pseudocode is numbered, even if a statement runs over one line
  • Comments in pseudocode are preceded by two forward slashes // and continue until the end of the line. For multi-line comments, each line is preceded by //
  • Variables, constants, and data types are essential in pseudocode
  • Atomic type names
    • INTEGER: A whole number
    • REAL: A number capable of containing a fractional part
    • CHAR: A single character
    • STRING: A sequence of zero or more characters
    • BOOLEAN: The logical values TRUE and FALSE
  • Literals of data types
    • Integers: Written as normal in the denary system, e.g. 5, -3
    • Real: Always written with at least one digit on either side of the decimal point, zeros being added if necessary, e.g. 4.7, 0.3, -4.0, 0.0
    • Char: A single character delimited by single quotes, e.g. 'x', 'C', '@'
    • String: Delimited by double quotes. A string may contain no characters (i.e. the empty string) e.g. "This is a string", ""
    • Boolean: TRUE, FALSE
  • Identifiers
    Names given to variables, constants, procedures, and functions. Must be in mix case, start with a letter, and can only contain letters (A-Z, a-z) and digits (0-9)
  • Assignments
    The assignment operator is ←. Assignments should be made in the format: <identifier> ← <value>
  • Declaring arrays
    Arrays are fixed-length structures of elements of identical data type, accessible by consecutive index numbers. Lower bound should be explicitly stated. One-dimensional arrays are declared as DECLARE <identifier> : ARRAY[<l>:<n>] OF <data type>
  • Using arrays
    In main pseudocode statements, only one index value is used for each dimension in the square brackets
  • Allowed array assignment
    • mes[n+1]StudentNames[n]
    • SavedGameNoughtsAndCrosses
  • Statement should not refer to a group of array elements individually
  • Loop structure for assigning array elements individually
    1. FOR Index = 1 TO 30
    2. StudentNames[Index] ← ""
    3. NEXT Index
  • Values are input using the INPUT command
  • Values are output using the OUTPUT command
  • Input and Output statements
    • INPUT Answer
    • OUTPUT Score
    • OUTPUT "You have ", Lives, " lives left"
  • Standard arithmetic operator symbols are used: + (Addition), - (Subtraction), * (Multiplication), / (Division)
  • Resulting value of division operation should be of data type REAL, even if operands are integers
  • Logic operators used are AND, OR, and NOT
  • IF statements may or may not have an ELSE clause
  • IF statement without ELSE clause
    IF <condition> THEN <statements> ENDIF
  • IF statement with ELSE clause
    IF <condition> THEN <statements> ELSE <statements> ENDIF
  • Nested IF statements
    IF ChallengerScore > ChampionScore THEN IF ChallengerScore > HighestScore THEN OUTPUT ChallengerName, " is champion and highest scorer" ELSE OUTPUT Player1Name, " is the new champion" ENDIF ELSE OUTPUT ChampionName, " is still the champion" IF ChampionScore > HighestScore THEN OUTPUT ChampionName, " is also the highest scorer" ENDIF ENDIF