Photo AI

Louise writes a program to work out if a number entered by the user is odd or even - OCR - GCSE Computer Science - Question 3 - 2019 - Paper 1

Question icon

Question 3

Louise-writes-a-program-to-work-out-if-a-number-entered-by-the-user-is-odd-or-even-OCR-GCSE Computer Science-Question 3-2019-Paper 1.png

Louise writes a program to work out if a number entered by the user is odd or even. Her first attempt at this program is shown. 01 num = input("enter a number:") 0... show full transcript

Worked Solution & Example Answer:Louise writes a program to work out if a number entered by the user is odd or even - OCR - GCSE Computer Science - Question 3 - 2019 - Paper 1

Step 1

What is meant by a logic error?

96%

114 rated

Answer

A logic error occurs when a program runs without crashing but produces incorrect results due to flaws in the logic of the code. More specifically, the program may not follow the intended algorithm or produce an output that does not align with the expected outcome.

Step 2

Give a corrected version of line 02 that fixes the logic error.

99%

104 rated

Answer

To fix the logic error on line 02, the conditional should check if the number is even by verifying if the remainder when divided by 2 is equal to 0. The corrected line should read:

02 if num MOD 2 = 0 then

Join the GCSE students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

Other GCSE Computer Science topics to explore

;