OCR GCSE Computer Science Computational thinking, algorithms and programming (02), June 2025: Question 2

12 marks · Medium difficulty · Short Answer

Trace a flowchart containing iteration for given inputs, identify and describe types and constructs of iteration and other programming constructs, and identify and describe IDE tools used when implementing the algorithm.

Practise this question

Question

A flowchart starts at Start, inputs x, enters a loop that outputs 'OK', decrements x by 2 (x = x - 2), and checks the decision condition 'IS x < 0?'. If False, the flow loops back to output 'OK'. If True, the flow terminates at End. Part (a) asks to complete a table with the number of times 'OK' is output for inputs 3 and 10. Part (b)(i) asks to identify and describe two different examples of iteration in a high-level language. Part (b)(ii) asks to name two other programming constructs. Part (c) asks to identify and describe two tools in an IDE that a programmer could use to create a program from the flowchart.
Question text

2 This flowchart uses iteration.

Start

INPUT x

OUTPUT "OK"

x = x - 2

FALSE

IS x < 0?

TRUE

End

(a) Complete the table by identifying how many times "OK" will be output for when each value is input.

Input value Number of times "OK" is output

[2]

(b) Iteration is a programming construct.

(i) Identify and describe two different examples of iteration that can be used in a high-level

language.

1 …

2 …

[4]

(ii) Give the names of two other programming constructs that are used in a high-level language.

1 …

2 …

[2]

(c) A programmer implements the flowchart as a program in a high-level language using an

Integrated Development Environment (IDE).

Identify and describe two tools that the programmer could use in the IDE to create a program

from the flowchart.

Tool 1 …

Description …

Tool 2 …

Description …

[4]

Mark scheme

Show the mark scheme Mark scheme for Question 2 detailing: (a) 2 and 6 for the respective inputs. (b)(i) 2 marks per construct for FOR (count controlled), WHILE (condition controlled, tested before), or DO UNTIL / REPEAT UNTIL (condition controlled, tested after). (b)(ii) Sequence and Selection (1 mark each). (c) 1 mark for each tool named (e.g. editor, debugger, run-time environment, translator, variable watch, breakpoints) and 1 mark for a matching description.

Question Answer Mark Guidance

2 (a) • 2 2

• 6

2 (b) (i) 2 marks per construct max 4 Marks are independent, allow mark for description

• FOR even if example/type of loop not given. Allow any 2

• Count controlled per construct.

• repeats a specified number of times

Allow suitable examples from other high-level

• WHILE languages.

• Condition controlled

• repeats while a condition is true / until a If WHILE and DO UNTIL given, allow “condition

condition is false // condition tested before controlled” as description of both. Do not give

code runs “condition controlled” twice if no other

differentiation between types of iteration.

• DO UNTIL / REPEAT UNTIL

Do not allow “repeats infinitely” – this is only true if

• Condition controlled

the condition is never met.

• repeats until a condition is true / while a

condition is false // condition tested after

Do not allow mismatched answers (e.g. “a while

code runs

loop repeats until a condition is true”)

2 (b) (ii) • Sequence 2 Allow slight alternatives (e.g. sequencing) Do not

• Selection allow examples by themselves (e.g. IF)

Allow branching as an alternative to selection.

2 (c) 1 mark for tool 14 4 Allow other sensible names for features.

1 mark for matching description

e.g. Description must add more than is given in the

• Text/code editor… identification of the feature to be awarded. For

• …allows program code to be written / example, “keyword highlighting, highlights

entered / changed keywords” is 1 mark for the feature only.

• …allows errors to be fixed

If compiler and interpreter given as two distinct

• Debugger / error reporting / diagnostics… features, allow both (with suitable descriptions). Do

• …identifies / finds / checks for errors not allow translator and compiler/interpreter.

• …shows location / detail of errors

• …suggests fixes Description must match tool. If tool name

wrong / missing, do not give description.

• Run-time environment / output window…

Allow sensible references to AI where appropriate.

• …allows program / code to be run /

executed

Allow other sensible features of an IDE (e.g. line

• …shows output of the program / code

numbering, auto indent, collapsed blocks, etc) with

suitable description. Description must add (slightly)

• Translator / compiler / interpreter …

more than just repeating the feature name.

• … convert to low-level/machine code

• …allow program to be executed / run Do not allow features of programming languages

• …produce executable file (only for compiler) (comments, casting, etc).

• …stops execution when error found

(interpreter only) For text editor / error diagnostics / debugger, allow

other sensible features listed as features in the

• Stepping … mark scheme as description (e.g. “text editor does

• … execute/run the program line by line pretty printing”, “debugger does stepping”)

• Variable watch…

• … see the contents/data held in variables /

see how (contents of) variables change

• Break points …

• … will allow the program to stop at a

chosen / set position

• Pretty printing // keyword highlighting…

• … allows keywords / variables to be

coloured / identified

• Keyword completion // autocomplete //

autocorrect // syntax suggestion…

• …suggests/corrects code/syntax (when first

part entered).

• GUI (builder)…

• …allows creation of user interface / buttons

/ by example

How to answer it

Algorithm Tracing, Constructs & IDE Tools

What this question tests

This question assesses your core knowledge of computational logic and software development fundamentals:

  • Flowchart dry running: Tracing iteration and decision logic line by line to determine output counts.
  • Basic programming constructs: Naming and defining the three fundamental constructs (Sequence, Selection, Iteration).
  • Types of iteration: Differentiating between count-controlled ( FOR ) and condition-controlled ( WHILE , DO UNTIL ) loops.
  • Features of an IDE: Identifying and describing software tools used by developers to code, test, translate, and debug programs.
Part (a) • 2 Marks

Flowchart Dry Run & Loop Counting

📐 Step-by-Step Flowchart Trace

Trace for input value 3:

  1. Outputs "OK" (Count = 1) → x = 3 - 2 = 1 → Is 1 < 0? FALSE (loops back).
  2. Outputs "OK" (Count = 2) → x = 1 - 2 = -1 → Is -1 < 0? TRUE → Ends.

Trace for input value 10:

  1. Outputs "OK" (1) → x = 8 → 8 < 0 is FALSE
  2. Outputs "OK" (2) → x = 6 → 6 < 0 is FALSE
  3. Outputs "OK" (3) → x = 4 → 4 < 0 is FALSE
  4. Outputs "OK" (4) → x = 2 → 2 < 0 is FALSE
  5. Outputs "OK" (5) → x = 0 → 0 < 0 is FALSE (0 is not less than 0!)
  6. Outputs "OK" (6) → x = -2 → -2 < 0 is TRUE → Ends.

✅ Completed Table

Input value Number of times "OK" is output
3 2
10 6
Mark Scheme: 1 mark for each correct value.

❌ Common Errors to Avoid

  • Assuming 0 terminates the loop: The condition is x < 0 , not x ≤ 0 . When x = 0 , the decision is FALSE, leading to one final iteration where "OK" is printed a 6th time.
  • Off-by-one errors: Notice that the output is displayed before x is decremented and checked. Always trace strictly in order.

🧠 Exam Technique: Quick Scratch Trace

Always draw a mini trace table in the blank space on the exam paper:

Columns: x start → Output → x = x - 2 → x < 0?
Tracing step-by-step prevents mental arithmetic slips!
Part (b)(i) • 4 Marks

Types of Iteration Constructs

💡 Key Knowledge: Two Core Categories of Loops

In high-level languages, loops are either count-controlled (fixed repetitions) or condition-controlled (repeats based on a Boolean test).

✅ Model Answers (Choose Any Two)

  • Option 1: FOR loop
    Description: A count-controlled loop that repeats a specified / predetermined number of times.
  • Option 2: WHILE loop
    Description: A condition-controlled loop that repeats while a condition is true (or until it becomes false), testing the condition before the code runs.
  • Option 3: DO UNTIL / REPEAT UNTIL loop
    Description: A condition-controlled loop that repeats until a condition becomes true, testing the condition after the code runs (always executes at least once).
Mark Scheme: 2 marks per construct (1 mark for identifying the loop/type, 1 mark for an accurate matching description). Maximum 4 marks.

❌ Common Errors & Examiner Warnings

  • Writing "repeats infinitely": This is incorrect; loops only run forever if there is a logic bug where the exit condition is never met.
  • Mismatched conditions: Stating that a WHILE loop "repeats until a condition is true" loses the description mark (a WHILE loop runs while true, stopping when false).
  • Duplicate descriptions: If you write both WHILE and DO UNTIL , simply writing "condition-controlled" for both will only earn the description mark once unless you explain their difference (e.g. pre-check vs post-check).
Part (b)(ii) • 2 Marks

The Fundamental Programming Constructs

✅ Model Answer

  1. Sequence
  2. Selection (or branching)
Mark Scheme: 1 mark per correct construct. Total = 2 marks.

💡 The Three Golden Building Blocks

All structured computer programs are built from just three basic constructs:

  • Sequence: Executing instructions one after another in order.
  • Selection: Making decisions based on conditions ( IF / ELSE , SWITCH ).
  • Iteration: Repeating blocks of code ( FOR , WHILE ).

❌ Examiner Trap

Do not write specific language keywords like IF or IF...ELSE on their own. The question asks for the programming construct itself, which is Selection.

Part (c) • 4 Marks

Integrated Development Environment (IDE) Tools

✅ Model Answers (Any Two Pairs)

  • Tool 1: Code / Text Editor
    Description: Allows the programmer to enter, write, and modify the high-level program code directly.
  • Tool 2: Translator / Compiler / Interpreter
    Description: Converts the high-level source code into low-level machine code / binary so the processor can execute it.
  • Tool 3: Debugger / Error Diagnostics
    Description: Identifies and highlights errors (syntax/runtime), displays their line numbers, and suggests fixes.
  • Tool 4: Run-time Environment
    Description: Allows the program to be run and tested directly within the IDE, displaying output to the user.
Mark Scheme: 1 mark for named tool, 1 mark for matching description. (2 × 2 marks = 4 marks total). Description must match the tool.

🧠 Exam Technique: Clear Descriptions

Your description must provide more detail than just repeating the tool's name:

  • Editor: ✗ "Edits code" → ✓ "Allows code to be typed, formatted, and changed."
  • Translator: ✗ "Translates code" → ✓ "Converts high-level code to machine code."
  • Debugger: ✗ "Debugs errors" → ✓ "Locates bugs and provides line numbers and error details."

💡 Other Accepted IDE Tools

  • Breakpoints: Pauses execution at a specific line of code to inspect program behaviour.
  • Variable Watch: Displays the current value of variables in real time as the program executes step by step.
  • Keyword Highlighting / Pretty Printing: Uses colours to distinguish keywords, variables, and strings for readability.
  • Autocomplete / Code Completion: Predicts and suggests commands or variable names as you type.

Topics

2.1 Algorithms · 2.2 Programming fundamentals · 2.5 Programming languages and Integrated Development Environments · 2.1.2 Designing, creating and refining algorithms · 2.2.1 Programming fundamentals · 2.5.2 The Integrated Development Environment (IDE)

Question and mark scheme from the OCR GCSE Computer Science examination, Computational thinking, algorithms and programming (02), June 2025. QuestionVault is an independent revision resource; questions remain the copyright of the awarding body.