Six original Cambridge-style questions on variables, constants, expressions and built-in functions, with mark points.
CONSTANT Name = literal, declared at the start, never assigned again.Explain the difference between a variable and a constant.
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)
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 ✓Code holds the string "CS9618-AS". State the value returned by:
(a) LENGTH(Code) (b) MID(Code, 3, 4) (c) RIGHT(Code, 2)
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.
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. ✓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.