Algorithmic Problem-Solving Guides: Converting Worded Problems Into Pseudocode (Copy)
Converting Worded Problems Into Pseudocode
What This Skill Actually Tests
- This topic tests whether you can:
- Understand English instructions
- Translate intent into logic
- Write structured, readable pseudocode
- Examiners are not testing programming languages
- They are testing:
- Logical thinking
- Sequencing
- Correct use of selection, iteration, arrays, variables
Core Examiner Rule (Non-Negotiable)
- Pseudocode must match the meaning of the words
- Not the style
- Not the syntax you like
- The logic implied by the wording
The 7-Stage Translation Method (Use This Every Time)
Stage 1: Strip The Problem Down To Plain Meaning
- Ignore story, names, fluff
- Focus on:
- What data comes in?
- What must go out?
- What rules apply?
Example (Worded)
“A program inputs 8 temperatures and displays how many are above 30.”
Stripped Meaning
- Input: 8 numbers
- Condition: > 30
- Output: count
Stage 2: Highlight Command Words (Very Important)
| Word / Phrase | Meaning In Code |
|---|---|
| input / enter / read | INPUT |
| display / show / print | OUTPUT |
| how many | Counter |
| total / sum | Accumulator |
| highest / lowest | Max / Min |
| each / every | Loop |
| until | REPEAT UNTIL |
| while | WHILE |
| if | IF |
Stage 3: Decide Variables Before Writing Any Code
Example Variable Plan
| Purpose | Variable |
|---|---|
| Loop counter | i |
| Input value | num |
| Counter | count |
| Total | total |
| Flag | found |
- Examiner likes clear, meaningful names
Written and Compiled By Sir Hunain Zia (AYLOTI), World Record Holder With 154 Total A Grades, 7 Distinctions and 11 World Records For Educate A Change AS Level Computer Science Full Scale Course
Stage 4: Decide The Control Structures From The Words
Use This Mapping (Exam-Safe)
| Wording In Question | Structure |
|---|---|
| “for each” | FOR |
| “repeat until valid” | REPEAT UNTIL |
| “keep asking while” | WHILE |
| “only if” | IF |
| “otherwise” | ELSE |
Example
“Keep asking until a positive number is entered”
→ REPEAT UNTIL
Stage 5: Break The Problem Into Logical Steps
Examiner-Preferred Order
- Initialise variables
- Input
- Process
- Output
Skeleton Template
<initialise>
<loop>
<input>
<processing>
</loop>
<output>
Worked Example 1 (Basic Translation)
Worded Problem
“Input 5 numbers and display how many are even.”
Step-by-Step Thinking
- Repetition: 5 times → FOR
- Condition: even → MOD 2 = 0
- Output: count
Pseudocode
count ← 0
FOR i ← 1 TO 5
INPUT num
IF num MOD 2 = 0 THEN
count ← count + 1
ENDIF
NEXT i
OUTPUT count
- No unnecessary arrays
- Clean logic
- Full marks structure
Written and Compiled By Sir Hunain Zia (AYLOTI), World Record Holder With 154 Total A Grades, 7 Distinctions and 11 World Records For Educate A Change AS Level Computer Science Full Scale Course
Worked Example 2 (Validation Problem)
Worded Problem
“The program should only accept a mark between 0 and 100.”
Key Wording
- “only accept” → validation
- Unknown attempts → REPEAT UNTIL
Pseudocode
REPEAT
INPUT mark
UNTIL mark >= 0 AND mark <= 100
- Minimal
- Correct
- Examiner-friendly
Worked Example 3 (Counting With Condition)
Worded Problem
“Input 12 ages and display how many are over 18.”
Logic Breakdown
- Input repeated → FOR
- Condition → IF
- Counting → counter
Pseudocode
count ← 0
FOR i ← 1 TO 12
INPUT age
IF age > 18 THEN
count ← count + 1
ENDIF
NEXT i
OUTPUT count
Worked Example 4 (Array-Based Translation)
Worded Problem
“Store the marks of 10 students and then display the average mark.”
Key Decisions
- Need later access → array
- Average → sum + divide
Pseudocode
total ← 0
DECLARE marks : ARRAY[1..10] OF INTEGER
FOR i ← 1 TO 10
INPUT marks[i]
total ← total + marks[i]
NEXT i
average ← total / 10
OUTPUT average
Written and Compiled By Sir Hunain Zia (AYLOTI), World Record Holder With 154 Total A Grades, 7 Distinctions and 11 World Records For Educate A Change AS Level Computer Science Full Scale Course
Worked Example 5 (Search Problem)
Worded Problem
“Input 15 numbers and display ‘Found’ if the number 7 is present.”
Logic Breakdown
- Need to scan all or until found
- Early exit allowed → WHILE + flag
Pseudocode
found ← FALSE
index ← 1
WHILE index <= 15 AND found = FALSE DO
INPUT num
IF num = 7 THEN
found ← TRUE
ELSE
index ← index + 1
ENDIF
ENDWHILE
IF found = TRUE THEN
OUTPUT "Found"
ELSE
OUTPUT "Not Found"
ENDIF
Handling Multi-Instruction Worded Problems
Examiner Trick
- One paragraph = multiple tasks
Example
“Input 20 numbers, store them, then display the largest even number.”
Sub-Tasks
- Input values
- Check even
- Track maximum
Pseudocode
max ← -1
FOR i ← 1 TO 20
INPUT num
IF num MOD 2 = 0 AND num > max THEN
max ← num
ENDIF
NEXT i
OUTPUT max
Written and Compiled By Sir Hunain Zia (AYLOTI), World Record Holder With 154 Total A Grades, 7 Distinctions and 11 World Records For Educate A Change AS Level Computer Science Full Scale Course
Common Translation Mistakes (High-Frequency)
Mistake 1: Writing Code Before Planning
- Leads to missing conditions
Mistake 2: Overusing Arrays
- Using arrays when no later access needed
Mistake 3: Ignoring “How Many” / “Total”
- Forgetting counters and accumulators
Mistake 4: Wrong Loop Choice
- FOR used when attempts unknown
- WHILE used when FOR is simpler
Mistake 5: Forgetting Output
- Logic done
- No OUTPUT statement
Examiner-Safe Translation Checklist
- Have I identified all inputs?
- Have I identified all outputs?
- Does each worded rule appear in code?
- Are variables initialised?
- Will the loop always stop?
- Is the solution simple?
Exam-Ready Translation Template (Use This)
<initialise variables>
FOR / WHILE / REPEAT
INPUT
PROCESS
END LOOP
OUTPUT result
Written and Compiled By Sir Hunain Zia (AYLOTI), World Record Holder With 154 Total A Grades, 7 Distinctions and 11 World Records For Educate A Change AS Level Computer Science Full Scale Course
One-Line Rules To Memorise
- Translate meaning, not words
- Break sentences into actions
- Choose simplest structure
- Initialise everything
- Clarity beats cleverness
