The longest questions ask you to write an algorithm for a scenario, or to change one you are given. Marks come for each working part: prompts and inputs, validation, loops, totals and counts, and clear outputs. Write precisely, in pseudocode, program code or a flowchart.
An algorithm must be precise: write Score > Target, not "score is bigger than the target". Build a solution from the standard parts: initialise variables, prompt and input, validate, process inside a suitable loop (totalling, counting, max/min), then output clear results. Use meaningful identifiers. To amend an algorithm, keep what works and add or change only the lines needed.
Examiners can only award marks for statements a computer could follow. Compare these two versions of the same step.
| Not acceptable | Acceptable |
|---|---|
| if the score is bigger than the target | IF Score > Target |
| add the price on | Total ← Total + Price |
| keep asking until it is right | REPEAT ... UNTIL Guess = Secret |
| print the answer | OUTPUT "Total cost: ", Total |
TotalTickets, not x.CONSTANT Price ← 5.50.Describing the algorithm in English sentences earns little or nothing. Write statements: INPUT, OUTPUT, ←, IF, loops.
Run the standard methods programs in the lab, then see how the same patterns combine into one full answer to a scenario.
DECLARE Tickets, Customer, TotalTickets, FourCount : INTEGER
DECLARE Takings : REAL
CONSTANT Price ← 5.50
TotalTickets ← 0
FourCount ← 0
FOR Customer ← 1 TO 30
REPEAT
OUTPUT "Number of tickets (1 to 4)"
INPUT Tickets
IF Tickets < 1 OR Tickets > 4
THEN
OUTPUT "Invalid: enter a whole number from 1 to 4"
ENDIF
UNTIL Tickets >= 1 AND Tickets <= 4
TotalTickets ← TotalTickets + Tickets
IF Tickets = 4
THEN
FourCount ← FourCount + 1
ENDIF
NEXT Customer
Takings ← TotalTickets * Price
OUTPUT "Total money taken: $", Takings
OUTPUT "Customers who bought 4 tickets: ", FourCount
Put the validation loop inside the customer loop, around the INPUT. Validating once before the main loop checks only the first customer.
Four quick checks. Each correct answer earns XP and records this skill on your profile.
Which statement is precise enough for an exam algorithm?
What should come immediately before an INPUT statement in a well-written algorithm?
In the flowchart in Fig. 1, which symbol holds Number = -1?
In the ticket algorithm, why is the REPEAT loop inside the FOR loop?
Fig. 1 is a flowchart; the first program below is the same algorithm in pseudocode. The second program amends it to also output the average, changing only what is needed.
// the flowchart in Fig. 1
Total ← 0
INPUT Number
WHILE Number <> -1 DO
Total ← Total + Number
INPUT Number
ENDWHILE
OUTPUT Total
// amended: also count the numbers and output the average
Total ← 0
Count ← 0
INPUT Number
WHILE Number <> -1 DO
Total ← Total + Number
Count ← Count + 1
INPUT Number
ENDWHILE
OUTPUT Total
IF Count > 0
THEN
OUTPUT "Average: ", Total / Count
ENDIF
Count > 0 before working out the average?When amending, keep the original identifiers and structure. Adding a whole new loop, or renaming variables, risks breaking the parts that already worked.
Unlocks once the four checks above are done. Worth more XP, written to IGCSE Paper 1 standard.
Which loop is the best choice to process exactly 25 exam scores?
With the inputs 10, 20, -1, what does the amended algorithm output for the average?
An algorithm must be amended to also output the smallest value input. Which pair of changes is needed?
Which is a correct Cambridge pseudocode constant declaration?
This skill is now recorded on your profile. Keep the chain going.