Question 5
OCR Computer Science November 2021 Paper 1GCSE6 marks
On the specification
- 1.3 Storage2.2 Programming techniques2.6 Data representation
Question text
5 A program is being created to convert the data capacity of a storage device into a different measure. The function, calculate(), takes the measurement (e.g. gigabytes) and the number (e.g. 2) as two parameters. It then returns the value in bits. The function returns –1 if an invalid measurement was entered. Complete the function calculate function calculate( , number) if measurement = = "gigabytes" then value = number * 1024 * 1024 * 1024 * 8 elseif measurement = = " " then value = number * 1024 * 1024 * 8 elseif measurement = = " " then value = number * 1024 * 8 elseif measure = = "bytes" then value = number * else endif return endfunction [6]