Computer Science • Pseudocode

AS Pseudocode

AS Pseudocode — Explanation

Write pseudocode the way the Cambridge International AS & A Level Computer Science (9618) papers expect it, then run it. Your code is checked strictly against the 9618 Pseudocode Guide for Teachers:

As in Paper 2, many questions ask for one function or procedure to a specification: write just that. A test program, shown under How it's tested, runs after your code and calls it.

Errors are listed under your code, and the program won't run until they're fixed. Style notes are how the 9618 guide writes things: your program still runs, but it's worth matching. Run runs your program in the run window (INPUT asks you there); Step goes a statement at a time; the trace table fills in as it runs.

Check answer runs your program on the question's tests, some of them hidden, so it has to work for any input. Prompts, capitals, spaces and punctuation in the output don't matter. If it's not right, you're told which test it failed and what that suggests, never the answer. Hint halves the question's marks; Show me shows a program that works, and the question scores nothing. Playground is a free editor.

Signed in, your code is saved as you go. Topics your teacher has set come up first.

Objective: Cambridge International AS & A Level Computer Science 9618, AS topics 9 Algorithm design and problem-solving, 10 Data types and structures (records, 1D and 2D arrays, text files), 11 Programming (constructs, procedures and functions, parameters by value and by reference, built-in functions) and 12.3 Program testing, written as set out in the 9618 Pseudocode Guide for Teachers.

Where this fits

  • Cambridge: Cambridge A Level Computer Science (9618); Cambridge AS Level Computer Science (9618)

AS Pseudocode — Key Terms

Key concepts in English, with te reo Māori, Chinese (Simplified) and Korean.

EnglishTe reo Māori中文(简体)한국어What it means on this page
Constantno attested term——A named value that is set when it's declared and can't be changed while the program runs, such as CONSTANT Rate = 0.15.
Declarationno attested term——A statement that names a variable and gives its data type before it's used, such as DECLARE Total : INTEGER.
Assignmentno attested term——Giving a variable a value. Pseudocode writes it with an arrow: Total ← 0.
STRINGno attested term——A data type for a sequence of zero or more characters, written in double quotes, such as "Kia ora".
CHARno attested term——A data type for exactly one character, written in single quotes, such as 'A'.
Parameterno attested term——A value passed to a procedure or function when it's called, named in its header, such as Size in PROCEDURE Line(Size : INTEGER).
Library Routineno attested term——A ready-made procedure or function that comes with a language, such as LENGTH, ROUND or RANDOM.
Linear Searchno attested term——Checking each item of a list in turn, from the start, until the item being searched for is found or the end is reached.
Text Fileno attested term——A file of lines of text, read or written a line at a time, which keeps its data after the program ends.
Recordno attested term——A data structure that groups related items of different data types under one name; each item is a field.
By Referenceno attested term——Passing a parameter as the caller's own variable (its address), so a change made in the subroutine changes the caller's variable too (BYREF).
By Valueno attested term——Passing a copy of a value as a parameter, so a change made in the subroutine doesn't affect the caller's variable (BYVAL).
Bubble Sortno attested term——A sort that passes through a list again and again, comparing each pair of neighbours and swapping them if they're in the wrong order, until a pass makes no swaps.
Concatenationno attested term——Joining strings end to end to make one string; 9618 pseudocode uses &: "Kia " & "ora".
Pseudocodeno attested term伪代码의사코드A structured, language-independent way of writing an algorithm, using keywords like IF, FOR and WHILE.
Variabletāupe变量변수A named location that holds a value which can change while the algorithm runs — the columns of the trace table.
Data typemomo raraunga数据类型자료형What kind of value a variable can hold — for example INTEGER, REAL, STRING or BOOLEAN.
INTEGERno attested term整数정수An SQL data type for whole numbers, such as a count or a mark.
REALno attested term实数실수An SQL data type for numbers with a decimal part, such as a height or a price.
BooleanPūreana布尔불Having only two possible values: 1 (true) or 0 (false).
Iteration (loop)koromeke循环(迭代)반복(루프)A block of steps that repeats — FOR, WHILE or REPEAT — while or until a condition holds.
Arrayhuānga数组배열An ordered list of values, all referred to by one name and an index, e.g. Numbers[3].
Functiontaumahi函数함수A named block of instructions that returns a value back to where it was called.
Procedurearamahi过程프로시저A named block of instructions that is run (CALLed) but does not return a value.
Trace tableno attested term追踪表추적표A table used to record the value of each variable, row by row, as an algorithm is dry-run by hand.
Validationno attested term数据验证 (shùjù yànzhèng)유효성 검사 (yuhyoseong geomsa)An automatic check by the computer, as data is entered, that the data is reasonable and follows set rules; it cannot tell whether the data is correct.

On the te reo Māori column. Terms marked as gaps have no attested equivalent in the sources checked — Karaitiana Taiuru's Dictionary of Māori Computer and Social Media Terms, Paekupu, the Reserve Bank's te reo financial glossary, NZQA and Te Aka. No coinage is printed as though it were established; where a class needs one, commission it from Te Taura Whiri i te Reo Māori and credit the translator. Te reo Māori is not italicised and takes no plural "s".