Six original Cambridge-style questions on selection and iteration in 9618 pseudocode, with mark points.
Explain the difference between a pre-condition loop and a post-condition loop, giving a suitable use for each.
The inputs are 4, 7, 10, 0, 3. Complete a trace table and state the output.
Total ← 0
Count ← 0
REPEAT
INPUT Value
IF Value MOD 2 = 0 THEN
Total ← Total + Value
ENDIF
Count ← Count + 1
UNTIL Value = 0 OR Count = 5
OUTPUT Total, " ", CountDay holds an integer. Write a CASE structure that outputs Weekday for 1 to 5, Weekend for 6 or 7 and Invalid day for any other value.
CASE OF Day ... ENDCASE ✓1 TO 5 : OUTPUT "Weekday" ✓6 TO 7 : OUTPUT "Weekend" (or two clauses 6 and 7) ✓OTHERWISE : OUTPUT "Invalid day" as the last clause. ✓A museum charges 5.00 for visitors under 12, 7.00 for ages 12 to 17 and 10.00 for ages 18 and over, except that students aged 18 or over pay 8.00. Write pseudocode using nested IF statements that inputs Age (INTEGER) and Student (BOOLEAN) and outputs the price.
INPUT Age and INPUT Student. ✓IF Age < 12 THEN Price ← 5.00 ELSE ... ✓IF Age <= 17 THEN Price ← 7.00 ELSE ... ✓IF Student = TRUE THEN Price ← 8.00 ELSE Price ← 10.00, with three correctly matched ENDIFs. ✓OUTPUT Price. ✓Choose the most suitable loop for each task and justify your choice.
(a) Output the 12 times table from 1 × 12 to 12 × 12.
(b) Keep asking for a PIN until the correct PIN is entered.
(c) Halve a value until it is below 1, where the value input may already be below 1.
Rewrite this loop using a WHILE loop so that it produces the same result, and state the final value of Total.
Total ← 0
FOR Index ← 1 TO 20 STEP 2
Total ← Total + Index
NEXT IndexTotal ← 0 and Index ← 1 before the loop. ✓WHILE Index <= 20 ... ENDWHILE. ✓Total ← Total + Index then Index ← Index + 2. ✓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.