This pseudocode algorithm totals all the numbers in the 0-indexed array scores
01 total = 0
02 for scoreCount = 1 to scores.length - 1
03 scores[scoreCount] = total + scores[scoreCount]
04 next scoreCount
05 print(total)
The function length returns the number of elements in the array - OCR - GCSE Computer Science - Question 2 - 2023 - Paper 2
Question 2
This pseudocode algorithm totals all the numbers in the 0-indexed array scores
01 total = 0
02 for scoreCount = 1 to scores.length - 1
03 scores[scoreCount] = t... show full transcript
Worked Solution & Example Answer:This pseudocode algorithm totals all the numbers in the 0-indexed array scores
01 total = 0
02 for scoreCount = 1 to scores.length - 1
03 scores[scoreCount] = total + scores[scoreCount]
04 next scoreCount
05 print(total)
The function length returns the number of elements in the array - OCR - GCSE Computer Science - Question 2 - 2023 - Paper 2
Step 1
State what is meant by a syntax error and a logic error.
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
A syntax error refers to a mistake in the code that violates the grammatical rules of the programming language, making it impossible for the code to compile or run successfully.
A logic error occurs when the program runs without crashing, but produces incorrect results due to flaws in the algorithm or reasoning behind the code.
Step 2
Identify two logic errors in the pseudocode algorithm.
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Error 1 line number: 03
Corrected line: scores[scoreCount] = total + scores[scoreCount]
This line should have a correct initialization and accumulation of total as total = total + scores[scoreCount].
Error 2 line number: 02
Corrected line: for scoreCount = 0 to scores.length - 1
The for loop should start from 0 since this is a 0-indexed array.