What keyword is used in pseudocode to represent a loop with a condition at its beginning?
Answer: The keyword is WHILE.
In Cambridge Computer Science (IGCSE 0478, O-Level 2210, A-Level 9618), a loop with its condition tested at the beginning is called a pre-condition loop. It uses the syntax WHILE <condition> DO ... ENDWHILE. If the test condition evaluates to FALSE at the very start, the loop statements execute 0 times.
1. Loop Types & Condition Placement in Cambridge Exams
Multiple-choice questions on Cambridge Computer Science Paper 2 frequently test your understanding of where loop conditions are evaluated and how many times the loop body is guaranteed to execute.
| Loop Construct | Loop Category | Condition Placement | Minimum Iterations | When to Choose |
|---|---|---|---|---|
WHILE ... DO ... ENDWHILE |
Pre-Condition (Indefinite) | At the beginning (before loop body) | 0 times | When condition must be true before running (e.g., checking if file has data or balance > 0) |
REPEAT ... UNTIL |
Post-Condition (Indefinite) | At the end (after loop body) | 1 time | When the action must run at least once (e.g., input validation prompt) |
FOR ... TO ... NEXT |
Count-Controlled (Definite) | Controlled by counter variable | Fixed by range | When the number of iterations is known before entering the loop |
Dry-Run These Loops in Our Online IDE
See how WHILE (pre-condition) vs REPEAT UNTIL (post-condition) execute line-by-line with interactive input prompts and trace table tracking.
2. Tricky Keyword & Syntax Rules (Past Paper Pitfalls)
Examiners deliberately set multiple-choice distractors based on syntax differences between Python and Cambridge pseudocode. Here are the rules you must memorize:
A. Assignment Arrow vs Equals Sign
In Cambridge pseudocode, variable assignment never uses the = symbol. Assignment is strictly written with an arrow:
// โ CORRECT: Assignment Total โ 0 Counter <- Counter + 1 // โ WRONG: '=' is only for comparison, never assignment Total = 0 // Syntax error in Cambridge exams! // โ CORRECT: Comparison in IF statement IF Total = 100 THEN OUTPUT "Target reached" ENDIF
B. All Keywords Must Be in UPPERCASE
Writing output, if, while, or declare in lowercase will lose you marks. Cambridge requires all keywords to be in ALL CAPS.
C. Array Indexing Starts at 1
Unlike Python or Java where arrays are 0-indexed, Cambridge pseudocode standard syllabus specifies 1-based arrays:
DECLARE StudentScores : ARRAY[1:30] OF INTEGER StudentScores[1] โ 95 // First element is at index 1
3. Interactive Exam MCQ Practice (With Explanations)
Test yourself with these actual exam-pattern multiple-choice questions:
What keyword is used in pseudocode to represent a loop with a condition at its beginning?
Show Answer & Explanation
Correct Answer: C) WHILE
A WHILE loop tests its condition at the very beginning (WHILE <condition> DO) before any statements in the loop body execute. REPEAT tests its condition at the end (UNTIL <condition>), and FOR is count-controlled rather than condition-controlled.
Which loop construct is guaranteed to execute the statements in its body at least once?
Show Answer & Explanation
Correct Answer: B) REPEAT ... UNTIL
Because REPEAT UNTIL is a post-condition loop, the loop body executes before the test condition is evaluated. Therefore, it always runs at least 1 time, even if the condition is immediately met.
Which of the following statements correctly assigns the value 25 to the variable Total in Cambridge pseudocode?
Show Answer & Explanation
Correct Answer: C) Total โ 25 (or Total <- 25)
Cambridge pseudocode strictly uses the assignment arrow โ. The single = sign is reserved exclusively for equality testing in conditional expressions.
What will be the final value output by this pseudocode fragment?
x โ 1
WHILE x < 8 DO
x โ x * 2
ENDWHILE
OUTPUT x
WHILE x < 8 DO
x โ x * 2
ENDWHILE
OUTPUT x
Show Answer & Explanation
Correct Answer: B) 8
Dry run: Start with x = 1. Iteration 1: 1 < 8 is TRUE โ x becomes 2. Iteration 2: 2 < 8 is TRUE โ x becomes 4. Iteration 3: 4 < 8 is TRUE โ x becomes 8. Loop check: 8 < 8 is FALSE โ loop exits. Final OUTPUT is 8.
4. Practice Full Exam Questions with Instant Grading
Want to test your pseudocode skills on realistic Cambridge past-paper style exercises? PseudoStudio includes an AI-powered practice environment with automated compiler testing and trace tables.