ExamBank Scot · N5 Computing Science question bank · All N5 Computing Science questions

N5 Computing Science 2017 Question 19

10 marks · Fixed and conditional loops

Louise realises that writing the code to read the data into the array like this is time consuming and not good practice. Write, using pseudocode or a programming language of your choice, the code to show how the data can be entered into the 1-D array using repetition. Another section of the program is shown below. . . . Line 119 SET averageHours = totalHours / 7 Line 120 <use a pre-defined function to store averageHours to the nearest whole number> Line 121 SEND “An average of ” & averageHours & “ hours” TO DISPLAY Identify the operator used to concatenate in the program above. Explain why averageHours should be stored as a real data type. The program is executed. At Line 119 the value 4·26 is assigned to averageHours. Write the message that will be displayed when Line 121 is executed. State the pre-defined function that could be used when Line 120 is coded. Louise gives a copy of her finished program to her friend who tells her that the program code is difficult to read. Explain how indentation can help readability in the program. State one other programming technique used to improve readability of programs. Louise is conducting a survey at her school to find out how many hours per week her class mates spend playing computer games. Louise will survey 100 pupils. The program assigns 100 names to a 1-D array as shown below. Line 1 DECLARE name AS ARRAY OF STRING INITIALLY [] Line 2 RECEIVE name[0] FROM KEYBOARD Line 3 RECEIVE name[1] FROM KEYBOARD Line 4 RECEIVE name[2] FROM KEYBOARD . . . . . . Line 101 RECEIVE name[99] FROM KEYBOARD

Marking scheme

Fixed loop 100 repetitions (1 mark) Correct Input (1 mark) Assignment to array (1 mark) Example answers: Repeat 100 times (1) Get input from keyboard (1) Store input in array/name (1) Repeat 100 times (1) Get input from keyboard (1) and store in array/name (1) For loop 1 to 100 times (1) Get name(loop) (1) from keyboard (1) & OR ampersand Also allow + AND averageHours may require a decimal point OR Division may result in a real number An average of 4 hours rounding of 4∙26 to 4 (1 mark) correct concatenation (1 mark) Round Not int/floor/ceiling as the program should round not always round down or always round up. Can show clearly where one construct starts and finishes Any one from: • Internal commentary • White space • Meaningful identifiers (1 mark each)

Previous question: N5 Computing Science 2017 Question 18

Next question: N5 Computing Science 2017 Question 20