Write pseudocode that reads 10 numbers from the user and outputs the largest value entered. Use a FOR loop.
4 marks
DECLARElargest, num, i : INTEGER INPUTlargest// seed with first value FORi<-2TO10 INPUTnum IFnum > largestTHEN largest<-num ENDIF NEXTi OUTPUT"Largest: ", largest
Common Mistakes
Don't lose easy marks
1
Using = for assignment in pseudocode — CAIE pseudocode uses <- (left arrow) for assignment, and = for comparison. Writing x = 5 instead of x <- 5 is an error.
2
Forgetting to close loops and conditionals — every FOR needs a NEXT, every WHILE needs an ENDWHILE, every IF needs ENDIF, every CASE needs ENDCASE. Missing these will lose marks.
3
Choosing the wrong loop type — use FOR when you know how many iterations. Use WHILE when condition must be checked before entering (may not run). Use REPEAT-UNTIL when loop body must run at least once (e.g. input validation).
Topic Summary — 2.1.2
What You Need to Know
ASSIGNMENT & I/O
x <- value (not =) INPUT / OUTPUT keywords DECLARE name : TYPE
SELECTION
IF-THEN-ELSE-ENDIF CASE OF-OTHERWISE-ENDCASE Operators: = <> < > <= >=
ITERATION
FOR i <- 1 TO n ... NEXT i WHILE cond DO ... ENDWHILE REPEAT ... UNTIL cond AND/OR/NOT · DIV/MOD
CSZone
Next Video
2.1.3
Searching Algorithms
Linear Search · Binary Search · Comparison
Head to CSZone.co.uk for the complete worksheet, quiz, and interactive tools