OCR GCSE Computer Science June 2024 Paper 2, Question 2: the odd or even flowchart

OCR J277/02 June 2024, Question 2: arrange five flowchart statements into a flowchart that decides whether a number is odd or even using MOD. The shapes, the labels and the four marks explained, with the algorithm to run.

Past paper questionOCR J277/02June 2024 Paper 24 marksComplete the algorithm

Question 2 of the OCR GCSE Computer Science Paper 2 sat on 21 May 2024 (J277/02, Computational thinking, algorithms and programming) gives you the statements of a flowchart and asks you to draw it. It is worth 4 marks, and three of them are for using the right shapes and joining them up.

We do not copy the exam paper here. Open it beside this page: OCR June 2024 J277/02 question paper (PDF). When you have finished, check the mark scheme too.

The question in short

An algorithm decides whether a number is odd or even. You are given: Start, INPUT num, the test if num MOD 2 == 0, OUTPUT "Odd", OUTPUT "Even" and End. The paper reminds you that an odd number divided by 2 leaves a remainder of 1.

The shapes

Statement Shape
Start, End rounded box (terminator)
INPUT num, both OUTPUTs parallelogram
num MOD 2 == 0 diamond (decision)

A plain rectangle is for a process, such as a calculation. There is none in this flowchart.

The flowchart

  1. Start leads to the parallelogram INPUT num.
  2. That leads to the diamond num MOD 2 == 0.
  3. The diamond has two exits. The one labelled True (or Yes) goes to OUTPUT "Even". The one labelled False (or No) goes to OUTPUT "Odd".
  4. Both outputs lead to End.

MOD gives the remainder. If the remainder after dividing by 2 is 0, the number divides exactly, so it is even. That is the True branch.

Where the four marks are

  • parallelograms for the input and both outputs;
  • a diamond for the decision;
  • True and False (or Yes and No) labelled the right way round, with True going to "Even";
  • every line joined up, and both branches reaching End.

Arrowheads are not needed. Lines are enough.

Where the marks are lost

  • True going to "Odd". The test asks "is the remainder 0?" Yes means even. Read the condition, not the order the outputs were printed in.
  • No labels on the diamond's exits. An unlabelled decision is ambiguous, and the label is a whole mark.
  • Rectangles for input and output. They must be parallelograms.
  • A branch that stops dead. Both outputs must connect to End.

Run it

The same algorithm in Python, where MOD is written %. The robot's light is green for even and blue for odd.

Try 7, then 10, then 0. Zero is even: 0 divided by 2 leaves no remainder.
The program
from bugbot import *
connect()

num = int(input("Enter a number: "))
if num % 2 == 0:
    led("green")
    print("Even")
else:
    led("blue")
    print("Odd")
Put this demo on your own site

Paste it into a school website, Moodle, Google Sites or a blog. More options on the embed page.

Questions

What is the answer to OCR J277 June 2024 Paper 2 Question 2?

Start, then INPUT num in a parallelogram, then a diamond with num MOD 2 == 0. The True exit goes to OUTPUT "Even" and the False exit goes to OUTPUT "Odd", both in parallelograms, and both lead to End.

What shapes are used in an OCR flowchart?

A rounded box for start and stop, a parallelogram for input and output, a rectangle for a process, a diamond for a decision, and a rectangle with double sides for a subprogram call. Lines join them in the order they happen.

How does MOD tell you whether a number is even?

MOD gives the remainder after division. An even number divided by 2 has a remainder of 0, and an odd number has a remainder of 1.

More from this paper

Every OCR J277 question we have worked

Learn it step by step

  1. F5.2 Flowcharts Algorithms
  2. F1.9 Arithmetic operators Programming basics
  3. F2.2 Selection: if Decisions and loops
Open the lessons

This is our own explanation of a published exam question. It is not written or endorsed by OCR, and the question paper and mark scheme remain OCR's copyright. Read them on OCR's site with the links on this page.