Every statement exact.

Six original Cambridge-style questions on variables, constants, expressions and built-in functions, with mark points.

Original questions All questions on this page are original work, written in the Cambridge AS & A Level style. They are not from past papers. They test the same concepts and skills the syllabus rewards.
Keep these straight

Literal, operator, function.

01
Recall
[2 marks]

Explain the difference between a variable and a constant.

  • A variable is a named memory location whose value can change while the program runs. ✓
  • A constant is given a (literal) value when it is declared and that value cannot change while the program runs. ✓
02
Calculate
[4 marks]

A holds 23 and B holds 4. Give the value of each expression.

(a) A DIV B (b) A MOD B (c) A / B (d) (A > 20) AND (B MOD 2 = 1)

  • (a) 5 ✓
  • (b) 3 ✓
  • (c) 5.75 ✓
  • (d) FALSE: A > 20 is TRUE but 4 MOD 2 = 0, so B MOD 2 = 1 is FALSE, and TRUE AND FALSE is FALSE. ✓
03
Convert
[4 marks]

Write pseudocode for this structured English. Declare everything you use.

1. SET Pi to 3.142 (this value never changes)
2. INPUT the radius of a circle
3. CALCULATE the area as Pi multiplied by the radius squared
4. OUTPUT a message and the area

  • CONSTANT Pi = 3.142 ✓
  • DECLARE Radius : REAL and DECLARE Area : REAL ✓
  • INPUT Radius and Area ← Pi * Radius * Radius ✓
  • OUTPUT "Area is ", Area ✓
04
Apply
[3 marks]

Code holds the string "CS9618-AS". State the value returned by:

(a) LENGTH(Code) (b) MID(Code, 3, 4) (c) RIGHT(Code, 2)

  • (a) 9 ✓
  • (b) "9618" ✓
  • (c) "AS" ✓
05
Write
[5 marks]

A full name such as Ada Lovelace contains exactly one space. Write pseudocode that inputs a full name and outputs the initials, for example AL. Use the functions LENGTH and MID.

  • Declare FullName, Initials (STRING) and Index (INTEGER); INPUT FullName. ✓
  • Initials ← MID(FullName, 1, 1) to take the first letter. ✓
  • FOR Index ← 2 TO LENGTH(FullName) ... NEXT Index. ✓
  • IF MID(FullName, Index, 1) = " " THEN Initials ← Initials & MID(FullName, Index + 1, 1) with ENDIF. ✓
  • OUTPUT Initials after the loop. ✓
06
Write
[3 marks]

Write pseudocode to generate a random whole number from 10 to 20 inclusive, store it in Number, and output Even or Odd as appropriate.

  • Number ← INT(RAND(11)) + 10 (RAND(11) gives 0 to below 11, INT gives 0 to 10). ✓
  • IF Number MOD 2 = 0 THEN ✓
  • OUTPUT "Even" ELSE OUTPUT "Odd" ENDIF. ✓

Mark this once you have attempted all six and checked your working. It records a Practiced badge on the topic and adds a one-time bonus. Revealing the solutions alone does not count.