Question 5

OCR Computer Science June 2023 Computer systems (H446-01)A level6 marks

On the specification

(a)
2.2 Problem solving and programming
(b)
2.2 Problem solving and programming
Question text

5 A doCheck() function takes an integer value as a parameter, carries out a series of calculations and returns an integer value. The function is shown here. function doCheck(number) temp = str(number) max = temp.length – 1 total = 0 for x = 0 to max total = total + int(temp.subString(x,1)) next x return total MOD 10 endfunction (a) State the value returned from the function when doCheck(3178) is called. [1] (b) Write an algorithm that will: • allow the user to enter an integer value • pass the value entered into the doCheck() function as a parameter • store both the value input and the value returned from the function in a text file with name "storedvalues.txt" You should write your algorithm using either pseudocode or program code. [5]