Candidate Surname

Other names

Centre Number

Candidate Number

Cambridge (CIE) AS Computer SciencePaper 2: Fundamental Problem-solving and Programming Skills (Set A)

Monday 30 November 2026

Afternoon (Time: 2 hours 0 minutes)

Total Marks

/ 75

Instructions

  • Try to complete this mock exam paper in one sitting, under exam conditions. Use all the time available and check your answers to each question at the end before submitting.

  • Remember this is PRACTICE. Mistakes are fine and will help you improve in time for the real exam - just do your best.

Materials

You may use the following built-in functions and operators in your pseudocode. In the real exam these are printed on a separate insert.

An error is generated if a function is called with parameters of the wrong type or value.

String and character functions

A string of length 1 may be treated as either a CHAR or a STRING. A CHAR may be assigned to, or joined with, a STRING. A STRING longer than one character cannot be assigned to a CHAR.

  • LEFT(ThisString : STRING, x : INTEGER) RETURNS STRING: the leftmost x characters of ThisString, e.g. LEFT("SUNFLOWER", 3) returns "SUN"

  • RIGHT(ThisString : STRING, x : INTEGER) RETURNS STRING: the rightmost x characters of ThisString, e.g. RIGHT("SUNFLOWER", 5) returns "LOWER"

  • MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING: y characters of ThisString, starting at position x, e.g. MID("SUNFLOWER", 4, 4) returns "FLOW"

  • LENGTH(ThisString : STRING) RETURNS INTEGER: the number of characters in ThisString, e.g. LENGTH("Blue Sky") returns 8

  • TO_UPPER(x : <datatype>) RETURNS <datatype>: x with every letter in upper case, where <datatype> is CHAR or STRING, e.g. TO_UPPER("Room 4b") returns "ROOM 4B"

  • TO_LOWER(x : <datatype>) RETURNS <datatype>: x with every letter in lower case, where <datatype> is CHAR or STRING, e.g. TO_LOWER('Q') returns 'q'

  • NUM_TO_STR(x : <datatype1>) RETURNS <datatype2>: a string version of a number, where <datatype1> is REAL or INTEGER and <datatype2> is CHAR or STRING, e.g. NUM_TO_STR(42.5) returns "42.5". A negative value gives a string that starts with '-'

  • STR_TO_NUM(x : <datatype1>) RETURNS <datatype2>: the numeric value of a string, where <datatype1> is CHAR or STRING and <datatype2> is REAL or INTEGER, e.g. STR_TO_NUM("61.25") returns 61.25

  • IS_NUM(ThisString : <datatype>) RETURNS BOOLEAN: TRUE if ThisString represents a valid numeric value, where <datatype> is CHAR or STRING, e.g. IS_NUM("-4.5") returns TRUE

  • ASC(ThisChar : CHAR) RETURNS INTEGER: the ASCII value of ThisChar, e.g. ASC('C') returns 67

  • CHR(x : INTEGER) RETURNS CHAR: the character whose ASCII value is x, e.g. CHR(68) returns 'D'

Numeric functions

  • INT(x : REAL) RETURNS INTEGER: the integer part of x, e.g. INT(15.92) returns 15

  • RAND(x : INTEGER) RETURNS REAL: a random real number from 0 up to but not including x, e.g. RAND(10) could return 7.315

Date functions

Dates are in the format DD/MM/YYYY unless stated otherwise.

  • DAY(ThisDate : DATE) RETURNS INTEGER: the day number, e.g. DAY(17/03/2025) returns 17

  • MONTH(ThisDate : DATE) RETURNS INTEGER: the month number, e.g. MONTH(17/03/2025) returns 3

  • YEAR(ThisDate : DATE) RETURNS INTEGER: the year, e.g. YEAR(17/03/2025) returns 2025

  • DAYINDEX(ThisDate : DATE) RETURNS INTEGER: the day of the week, where Sunday = 1, Monday = 2 and so on, e.g. DAYINDEX(17/03/2025) returns 2

  • SETDATE(Day, Month, Year : INTEGER) RETURNS DATE: the date Day/Month/Year, e.g. SETDATE(5, 9, 2025) returns the date 05/09/2025

  • TODAY() RETURNS DATE: the current date

Text file function

  • EOF(FileName : STRING) RETURNS BOOLEAN: TRUE if there are no more lines to read from FileName. The file must already be open in READ mode

Operators

  • & joins two strings, or a CHAR and a STRING, e.g. "Rain" & "bow" gives "Rainbow"

  • AND, OR, NOT are the logical operators on Boolean values, e.g. TRUE AND FALSE gives FALSE

  • MOD gives the remainder when one number is divided by another, e.g. 17 MOD 5 gives 2

  • DIV gives the integer part of one number divided by another, e.g. 17 DIV 5 gives 3

DON'T FORGET! Submit your paper at the end to receive marks and review your answers - using AI, mark schemes or solutions.

NOTE: You might want to use some scrap paper to plan your answers to longer questions, so get that prepared now.