Flowcharts and Pseudocode Revision Notes
Subject: Computer Science | Level: GCSE | Exam Board: OCR
Master the art of algorithmic thinking for your OCR GCSE Computer Science exam. This guide breaks down how to design solutions using flowcharts and pseudocode, turning complex problems into simple, logical steps that will earn you maximum marks in Component 02.
Revision Notes & Key Concepts
Key Terms & Definitions
- Algorithm
- A sequence of unambiguous instructions for solving a problem, or for accomplishing a task.
- Flowchart
- A diagram that represents a set of instructions or algorithm, using a set of standard symbols.
- Pseudocode
- A method of showing an algorithm using English-like statements that is not a true programming language but follows a set structure.
- Sequence
- A programming construct where instructions are executed one after another in order.
- Selection
- A programming construct where a choice is made between different paths of execution based on a condition.
- Iteration
- A programming construct where a block of code is repeated. This can be for a set number of times (count-controlled) or until a condition is met (condition-controlled).
- Trace Table
- A table used to test an algorithm by manually tracking the values of variables as the algorithm is executed step-by-step.
Worked Examples
Worked Example
Question: A teacher needs a program that allows them to enter the scores for 30 students in a test. The program should calculate and output the average score. **Write an algorithm using pseudocode** to solve this problem.
Solution: Step 1: Initialize variables. We need a variable to store the running total and a counter for the loop. `total = 0` Step 2: Create a count-controlled loop that runs 30 times. `for i = 1 to 30` Step 3: Inside the loop, ask for the student's score. `score = input("Enter score: ")` Step 4: Add the score to the running total. `total = total + score` Step 5: Close the loop. `next i` Step 6: After the loop, calculate the average. `average = total / 30` Step 7: Output the final average. `print("The average score is: " + average)` **Final Answer (in OCR Reference Language):** total = 0 for i = 1 to 30 score = input("Enter score: ") total = total + score next i average = total / 30 print(average)
Worked Example
Question: **Draw a flowchart** for an algorithm that asks the user to enter a password. If the password is "secret", it should output "Access granted". If the password is not "secret", it should output "Access denied".
Solution: The flowchart should be drawn using the correct symbols. Step 1: An oval 'Start' symbol. Step 2: A parallelogram 'INPUT password' symbol. Step 3: A diamond 'password == "secret"?' symbol. Step 4: From the 'Yes' branch of the diamond, a parallelogram 'OUTPUT "Access granted"' symbol. Step 5: From the 'No' branch of the diamond, a parallelogram 'OUTPUT "Access denied"' symbol. Step 6: Both output parallelograms should lead to an oval 'Stop' symbol.
Worked Example
Question: A program is needed to check if a number is positive, negative, or zero. **Write an algorithm using pseudocode** that takes a number as input and outputs one of three messages: "Positive", "Negative", or "Zero".
Solution: Step 1: Get the number from the user. `number = input("Enter a number: ")` Step 2: Use a nested IF statement to check the conditions. First, check if the number is greater than zero. `if number > 0 then` Step 3: If it is, print "Positive". `print("Positive")` Step 4: If not, use an `ELSEIF` to check the next condition: is the number less than zero? `elseif number < 0 then` Step 5: If it is, print "Negative". `print("Negative")` Step 6: If neither of the first two conditions were met, it must be zero. Use an `ELSE`. `else` Step 7: Print "Zero". `print("Zero")` Step 8: Close the `IF` statement. `endif` **Final Answer (in OCR Reference Language):** number = input("Enter a number: ") if number > 0 then print("Positive") elseif number < 0 then print("Negative") else print("Zero") endif
Practice Questions
Question: **Draw a flowchart** for an algorithm that asks for two numbers, and then outputs the larger of the two.
Answer:
Question: **Write an algorithm using pseudocode** to find the total of 10 numbers entered by a user.
Answer:
Question: A simple validation algorithm is required. **Write an algorithm using pseudocode** that repeatedly asks a user to enter a number until they enter a number between 1 and 10 (inclusive).
Answer:
Question: **Complete the trace table** for the following algorithm, showing the final output. a = 5 b = 3 while a > b print(a) a = a - 1 b = b + 1 endwhile | a | b | Output | |---|---|--------| | 5 | 3 | | | | | | | | | |
Answer:
Question: A cinema has a discount for children (under 16) and seniors (65 and over). **Write an algorithm using pseudocode** that takes a person's age and outputs either "Discount applies" or "Full price".
Answer:



