Learning Objectives
- analyse a problem statement and identify inputs, processing and outputs
- break a problem into clear algorithmic steps
- create algorithms using Cambridge IGCSE pseudocode
- represent algorithms using flowcharts
- amend an existing algorithm when a requirement changes
- select sequence, selection and iteration appropriately
- trace an existing solution before changing it
- test newly written and amended algorithms with suitable data
- check that a change has not broken required existing behaviour
- use clear identifiers and readable algorithm structure
Key Terms
| Term | Simple definition |
|---|---|
| Algorithm | A sequence of steps used to solve a problem. |
| Requirement | What the problem says the solution must do. |
| Input | Data supplied to the algorithm. |
| Processing | Calculations or decisions performed on data. |
| Output | Information produced by the algorithm. |
| Pseudocode | A structured text description of an algorithm. |
| Flowchart | A visual description of an algorithm using symbols and arrows. |
| Amend | Change an existing algorithm to meet a new or changed requirement. |
| Selection | Choosing between different paths using a condition. |
| Iteration | Repeating a statement or group of statements. |
| Dry-run | Manually following an algorithm using test data. |
| Logic error | The solution behaves incorrectly because the logic is wrong. |
1. Understand the Problem Before Writing
Before writing an algorithm, turn the question into a small set of precise requirements.
| Ask | Example: student result system |
|---|---|
| What is the input? | Student mark |
| What is the processing? | Compare the mark with the pass threshold |
| What is the output? | Pass or Fail |
- Identify the data entering the solution.
- Identify calculations, comparisons and decisions.
- Identify exactly what must be displayed or returned.
- Look for words such as IF, OTHERWISE, FOR, EACH, REPEAT and UNTIL.
- Break complex requirements into smaller steps before coding.
Activity 1A: Identify IPO
Classroom / homework activity
A program accepts a mark and displays Pass when the mark is 50 or above.
| Part | Answer |
|---|---|
| Input | Mark |
| Process | Compare mark with 50 |
| Output | Pass or Fail |
Activity 1B: Convert the requirement
Classroom / homework activity
Requirement: enter two numbers, add them and display the result.
- Input the first number.
- Input the second number.
- Add the numbers.
- Output the result.
Check Your Understanding
1. Why identify input, processing and output first?
- It clarifies what data is available.
- It identifies what the algorithm must do.
- It identifies the required result.
- It reduces the chance of missing a requirement.
2. Which words can suggest selection?
- If can indicate a decision.
- Otherwise can indicate an alternative path.
- A condition normally controls which branch is followed.
- In pseudocode this is commonly represented by IF.
3. Which words can suggest iteration?
- For can indicate a known number of repetitions.
- Each can indicate repeated processing.
- Repeat and until can indicate condition-controlled repetition.
- Recognising these words helps select a loop structure.
4. Why break a large problem into smaller steps?
- Smaller steps are easier to understand.
- Missing actions are easier to identify.
- Each step can be checked.
- The steps can then be represented in pseudocode or a flowchart.
5. Why should the output be clear before writing the algorithm?
- It defines what the solution must produce.
- It helps identify the required processing.
- It helps identify the final output statement.
- It provides something concrete to test.
2. Create an Algorithm from a Requirement
Creating an algorithm means converting the requirements into a logical sequence of instructions.
| Stage | What to decide |
|---|---|
| Inputs | What values are needed? |
| Variables | What values need to be stored? |
| Processing | What calculations or checks are required? |
| Control flow | Is sequence, selection or iteration needed? |
| Output | What result must be produced? |
DECLARE Mark1 : REAL
DECLARE Mark2 : REAL
DECLARE Average : REAL
INPUT Mark1
INPUT Mark2
Average ← (Mark1 + Mark2) / 2
OUTPUT "Average = ", AverageCambridge specifies declarations in the formDECLARE <identifier> : <data type>and uses←for assignment. Identifiers use mixed/Pascal case. fileciteturn19file0L72-L78 fileciteturn19file0L85-L100 fileciteturn19file0L105-L115
Activity 2A: Write a rectangle algorithm
Classroom / homework activity
Input Width and Height, calculate Area and output Area.
DECLARE Width : REAL
DECLARE Height : REAL
DECLARE Area : REAL
INPUT Width
INPUT Height
Area ← Width * Height
OUTPUT AreaActivity 2B: Add selection
Classroom / homework activity
Amend the rectangle solution so Area greater than 100 outputs Large; otherwise output Small.
IF Area > 100
THEN
OUTPUT "Large"
ELSE
OUTPUT "Small"
ENDIFCheck Your Understanding
6. What should be decided before detailed pseudocode is written?
- Identify the required input.
- Identify the processing.
- Identify the output.
- Choose suitable control structures.
7. Why use meaningful identifiers?
- They describe the stored value.
- They make the algorithm easier to read.
- They reduce ambiguity.
- They help another programmer understand the solution.
8. What is the Cambridge assignment operator?
- It is ←.
- It assigns a value to a variable or data item.
- It can assign the result of an expression.
- For example, Total ← Total + Number.
9. Why is indentation useful in pseudocode?
- It shows which statements are contained inside another statement.
- It makes IF structures clearer.
- It makes loops clearer.
- It reduces ambiguity in nested structures.
10. What is the benefit of writing plain-language steps first?
- The logic can be checked before syntax.
- Missing steps are easier to find.
- The plan can be translated into pseudocode.
- The same logic can be represented by a flowchart.
3. Amend an Existing Algorithm
When a requirement changes, the existing algorithm may need to be amended rather than completely rewritten.
- Read the complete existing algorithm first.
- State exactly what has changed.
- Locate the affected part.
- Keep correct existing logic whenever possible.
- Make the smallest suitable change.
- Trace and test the entire amended solution.
INPUT Mark
IF Mark >= 50
THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIFINPUT Mark
IF Mark >= 50
THEN
IF Mark >= 80
THEN
OUTPUT "Distinction"
ELSE
OUTPUT "Pass"
ENDIF
ELSE
OUTPUT "Fail"
ENDIFThe completed flowchart shows the original Pass/Fail decision and the new Distinction decision added only to the Pass branch.
Interactive amendment checker
Activity 3A: Change the pass mark
Classroom / homework activity
Change the pass threshold from 50 to 60.
INPUT Mark
IF Mark >= 60
THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIFActivity 3B: Add another grade
Classroom / homework activity
Add Excellent when the mark is 90 or above.
INPUT Mark
IF Mark >= 60
THEN
IF Mark >= 90
THEN
OUTPUT "Excellent"
ELSE
OUTPUT "Pass"
ENDIF
ELSE
OUTPUT "Fail"
ENDIFCheck Your Understanding
11. Why read the whole algorithm before changing it?
- You need to understand the existing logic.
- The change may depend on earlier steps.
- You might remove correct logic accidentally.
- You need to know which existing cases should continue working.
12. Why make the smallest necessary change?
- It reduces the risk of breaking working logic.
- The amendment is easier to understand.
- Testing becomes easier.
- The solution remains closer to the original.
13. What does the amended grading algorithm add?
- It keeps the original Pass/Fail decision.
- It adds a second condition.
- The second condition is inside the Pass branch.
- Marks of 80 or more produce Distinction.
14. Why test the complete solution after an amendment?
- A change may introduce a new logic error.
- Old cases may still be required.
- New cases need to demonstrate the changed requirement.
- Testing the whole solution checks for unintended effects.
15. What is an unintended side effect?
- A change causes another part of the solution to stop working correctly.
- The new requirement may work while an old case fails.
- The output may become incorrect for previous inputs.
- Careful testing can reveal it.
4. Flowcharts — Create and Amend Visually
The flowchart below is the visual version of the same Pass/Fail decision.
| Symbol | Meaning |
|---|---|
| Terminator | START / END |
| Rectangle | Process / calculation |
| Parallelogram | INPUT / OUTPUT |
| Diamond | Decision / condition |
| Arrow | Direction of flow |
OUTPUT "Pass"
OUTPUT "Fail"
Activity 4A: Plan the flowchart
Classroom / homework activity
For a program that validates a mark from 0 to 100, identify the major flowchart stages.
| Stage | Action |
|---|---|
| 1 | START |
| 2 | INPUT Mark |
| 3 | Decision: valid? |
| 4 | Output/process the selected path |
| 5 | END or repeat if required |
Proper Flowchart — Pass / Fail
A decision diamond creates the two paths. Both paths eventually rejoin at END.
Activity 4B: Add a new branch
Classroom / homework activity
A Pass/Fail flowchart now needs Distinction at 80 or above.
Add a second decision on the existing Pass branch:Mark ≥ 80?. This is the flowchart equivalent of the nested IF.
Check Your Understanding
16. What does a diamond represent?
- It represents a decision condition.
- It creates different branches.
- Each branch represents an outcome.
- The selected branch determines the next step.
17. Why must arrows be clear?
- They show execution order.
- They connect the stages.
- They show where each branch goes.
- They make the control flow understandable.
18. How can a flowchart be amended safely?
- Identify the changed requirement.
- Find the affected symbol or branch.
- Add or replace only the necessary part.
- Check all arrows after the change.
19. How is a flowchart decision related to IF?
- Both represent a condition.
- Both can produce different paths.
- A diamond is the visual form.
- IF is a pseudocode form.
20. Why can a flowchart help before coding?
- It gives a visual overview.
- Branches and loops are easy to see.
- Missing paths may be detected early.
- The logic can then be translated into pseudocode.
5. Choose the Correct Control Structure
| Structure | Use it for | Example |
|---|---|---|
| Sequence | Steps that always happen in order | INPUT → calculate → OUTPUT |
| Selection | A decision changes the path | IF Mark >= 50 THEN ... |
| Iteration | The same work must repeat | FOR Counter ← 1 TO 10 |
An algorithm can contain all three structures. When amending it, identify which structure the new requirement actually changes.
Activity 5A: Choose a structure
Classroom / homework activity
Choose the best structure for: calculate once; choose Pass/Fail; process ten scores.
| Task | Structure |
|---|---|
| Calculate once | Sequence |
| Pass/Fail | Selection |
| Process ten scores | Iteration |
Activity 5B: Change the repetition
Classroom / homework activity
A program processes 5 scores. The requirement changes to 10 scores.
Change the FOR loop boundary from1 TO 5to1 TO 10, provided the rest of the algorithm remains correct.
Check Your Understanding
21. When is sequence appropriate?
- All actions happen in order.
- No decision changes the path.
- No repeated block is required.
- It is the simplest control structure.
22. When is selection appropriate?
- A condition changes what happens next.
- Different cases can have different actions.
- IF is commonly used in pseudocode.
- A flowchart diamond can represent it.
23. When is iteration appropriate?
- The same work repeats.
- FOR suits a known number of repetitions.
- WHILE or REPEAT can suit condition-controlled repetition.
- The loop needs a suitable stopping rule.
24. Can one algorithm contain all three?
- Yes.
- Sequence can contain selection.
- Loops can contain selection.
- The structures can be combined to solve larger problems.
25. How do you know what part to amend?
- Compare the old and new requirements.
- Identify the affected control structure.
- Change the necessary part.
- Test the whole solution afterwards.
6. Test the New or Amended Algorithm
| Test | Purpose | Example |
|---|---|---|
| Normal | Check an ordinary valid case | 65 for Pass at 50 |
| Boundary | Check the exact limit and nearby values | 49, 50, 51 |
| Abnormal | Check invalid/out-of-range input | -5 or 105 for marks 0–100 |
| Changed requirement | Check new behaviour | 79, 80, 81 for Distinction at 80 |
Worked test set
| Mark | Expected output |
|---|---|
| 45 | Fail |
| 50 | Pass |
| 79 | Pass |
| 80 | Distinction |
| 95 | Distinction |
Exam tip
When a rule uses a boundary such as 50 or 80, test the boundary itself and values immediately below and above it. This helps detect mistakes such as > instead of >=.
Activity 6A: Select boundary tests
Classroom / homework activity
For Pass if Mark >= 50, choose three useful tests.
| Input | Reason |
|---|---|
| 49 | Below boundary |
| 50 | At boundary |
| 51 | Above boundary |
Activity 6B: Test the new Distinction rule
Classroom / homework activity
For Distinction at 80 or above, choose three boundary tests.
| Input | Expected |
|---|---|
| 79 | Pass |
| 80 | Distinction |
| 81 | Distinction |
Check Your Understanding
26. Why test a boundary value?
- It is where a decision can change branch.
- It checks the comparison operator.
- It confirms the threshold is handled correctly.
- Nearby values add further evidence.
27. What is a normal test?
- An ordinary valid input.
- It checks expected everyday behaviour.
- It normally follows the main path.
- It helps confirm the solution works normally.
28. What is an abnormal test?
- An invalid or out-of-range input.
- It checks validation or rejection.
- It can reveal missing conditions.
- The chosen value should match the limits in the requirement.
29. Why test existing cases after an amendment?
- Old behaviour may still be required.
- The amendment could break a previously correct case.
- New cases must show the changed requirement works.
- Testing both groups checks the complete solution.
30. How can tracing help after an amendment?
- It records changing variable values.
- It shows which branches are followed.
- It can reveal where new logic becomes incorrect.
- It supports checking the final output.
7. Exam-Style Writing & Amending Practice
Worked Example — Create then amend
Original:input five scores and output the total.
DECLARE Total : INTEGER
DECLARE Score : INTEGER
Total ← 0
FOR Counter ← 1 TO 5
INPUT Score
Total ← Total + Score
NEXT Counter
OUTPUT TotalChanged requirement:also output "High" when Total is 240 or more; otherwise "Standard".
DECLARE Total : INTEGER
DECLARE Score : INTEGER
Total ← 0
FOR Counter ← 1 TO 5
INPUT Score
Total ← Total + Score
NEXT Counter
OUTPUT Total
IF Total >= 240
THEN
OUTPUT "High"
ELSE
OUTPUT "Standard"
ENDIFFlowchart Version — Total of Five Scores
The loop in the pseudocode becomes a repeated flowchart path back to INPUT Score.
Activity 7A: 5-mark algorithm
Classroom / homework activity
Write an algorithm to input five numbers and output the total.
DECLARE Total : INTEGER
DECLARE Number : INTEGER
Total ← 0
FOR Counter ← 1 TO 5
INPUT Number
Total ← Total + Number
NEXT Counter
OUTPUT TotalActivity 7B: 4-mark amendment
Classroom / homework activity
Add an output for Total >= 100.
- Keep the existing total calculation.
- Add a condition testing Total >= 100.
- Output the required message when TRUE.
- Provide the specified alternative behaviour when FALSE.
Check Your Understanding
31. What clue suggests selection is needed?
- A condition changes the action.
- Words such as if or otherwise are clues.
- Different cases require different behaviour.
- Use an IF or a flowchart decision.
32. What clue suggests iteration is needed?
- Work is repeated.
- Words such as each or every are common clues.
- A FOR loop can handle a known repetition count.
- A condition-controlled loop needs a stopping condition.
33. Why preserve correct logic when amending?
- It already satisfies part of the requirement.
- Unnecessary changes increase the risk of errors.
- The amendment is easier to review.
- Testing becomes more focused.
34. Why should pseudocode and flowchart versions agree?
- They represent the same underlying algorithm.
- The processing should remain equivalent.
- The same conditions should produce the same branches.
- Only the representation changes.
Key Takeaways
- Understand the requirement before writing or changing the algorithm.
- Identify input, processing and output.
- Break complex requirements into clear steps.
- Use sequence, selection and iteration to match the task.
- Use Cambridge IGCSE pseudocode conventions for pseudocode answers.
- Read the existing solution before amending it.
- Make the smallest necessary change and preserve correct logic.
- Use flowchart symbols and arrows to show the same underlying logic.
- Test normal, boundary and abnormal cases where appropriate.
- Test both the new behaviour and important existing behaviour.
- Use tracing/dry-runs to check changing values and decisions.
Question Bank
1. Describe a systematic method for creating an algorithm from a problem specification. [5 marks]
- Identify the required inputs.
- Identify the processing or calculations.
- Identify the required outputs.
- Choose suitable sequence, selection and/or iteration.
- Write the solution and test it.
2. Explain how to amend an existing algorithm safely. [4 marks]
- Read the original algorithm.
- Identify the changed requirement.
- Change the necessary part while keeping correct logic.
- Test the complete amended solution.
3. Explain how pseudocode and flowcharts can represent the same algorithm. [5 marks]
- Pseudocode describes the logic with structured text.
- A flowchart describes the logic with symbols and arrows.
- Both can represent sequence, selection and iteration.
- The control flow should be equivalent.
- The representation changes, but the underlying logic remains the same.
4. Explain how to test an amended algorithm. [5 marks]
- Use normal valid data.
- Test boundary values.
- Test abnormal or invalid data when appropriate.
- Check expected and actual outputs.
- Retest important existing cases as well as new cases.
5. Explain sequence, selection and iteration. [4 marks]
- Sequence executes steps in order.
- Selection chooses a path based on a condition.
- Iteration repeats a statement or block.
- Choose the structure that matches the requirement.
6. A Pass/Fail solution gains a Distinction rule at 80 or above. Explain how you would amend it. [5 marks]
- Keep the existing input.
- Keep the outer pass condition.
- Add a second condition for 80 or above.
- Output Distinction when the second condition is TRUE and Pass otherwise.
- Test values below 50, 50–79 and 80 or above.
7. Why are meaningful identifiers and indentation important in Cambridge pseudocode? [4 marks]
- Meaningful identifiers make data and purpose clear.
- Cambridge uses mixed/Pascal case identifiers.
- Indentation shows contained statements.
- Clear structure makes the algorithm easier to follow.
8. Describe how to convert a written requirement into a flowchart. [5 marks]
- Identify START and END.
- Add input and output symbols.
- Add process steps for actions/calculations.
- Add decision symbols and connect each branch.
- Check that the arrows give a complete control flow.