Paper 2
Paper 2
Name: ................................................
1(a)Open Q01a in the code editor. Use the code to answer these questions.
(i) Give the text of a comment used in the code.
(1)
(ii) Give the text of a line that creates and initialises a variable.
(1)
(iii) Give the keyword that starts the selection used in the code.
(1)
(iv) Give a relational operator used in the code.
(1)
(v) Give a logical operator used in the code.
(1)
(b) Programs can have Logical errors.
(i) State what is meant by the term Logical error.
(2)
(ii) Give one example of a Logical error.
(1)
(c) Programmers write code and use subprograms. Global variables are different from local variables.
(i) State where a global variable is created and its use
(1)
(ii) State where a local variable is accessible and its use
(1)
2 (a) Below shows the Sales.txt file. It stores sales information.
Smith,264,140,120,284,192
Anne,420,377,435,376,392
Charlete,619,589,606,586,600
William,799,811,788,814,788
Robin,982,1007,1013,989,1009
Open Q02a in the code editor. Amend the code to produce the intended output. Do not add any further
functionality.
Save your code as Q02aFINISHED with the correct file extension for the programming language. (10)
(b) A merge sort algorithm can be used to sort a list into ascending order.
The list 4, 1, 7, 9, 3, 5, 2, 6 needs to be sorted.
Complete the merge sort using the space provided.
4, 1, 7, 9, 3, 5, 2, 6
1, 2, 3, 4, 5, 6, 7, 9 (5)
3 (a) Complete the table by giving an example value for each data type.
integer 12
char
real
Boolean
Float
String
(5)
(b) A program is required to calculate and display the result (name and average marks) for five students. The
flowchart for the algorithm is given below.
Open Q03b in the code editor. Write a program to implement the logic in the flowchart. Do not add any further
functionality. Save your code as Q03bFINISHED with the correct file extension for the programming language.
(10)
4 (a) Car registration codes consist of seven characters. The characters are ;
Open Q04a in the code editor. Amend the code to construct a new code.
Do not add any further functionality.
Save your code as Q04cFINISHED with the correct file extension for the programming language.
[6]
45 69 88 74 35 25
Tim uses a bubble sort algorithm to sort the marks. Complete the table to show how the bubble sort algorithm
will sort the marks. You may not need to use all the rows.
45 69 88 74 35 25
(4)
5 Anne is learning about sorting and searching algorithms.
(a) Anne’s friend has given her a partially completed program to carry out a binary search.
This pseudocode contains the logic required to complete the program.
Open Q05a in the code editor. Write a program to implement the logic in the pseudocode. Do not add any
further functionality. Save your code as Q05aFINISHED with the correct file extension for the programming
language. (6)
(b) Complete the trace table below with the input Item = 5
(4)
6 A financial company has several employees. Data collected for the employees is stored in arrays. The data
stored is:
The company wants to present the data to the director board to make year-end decisions about its staff.
Open the file Q06 in the code editor.