Programming – O Level Computer Science (2210)

174 questions · page 9 of 12 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
121
2210/22/O/N/19 · Question 6Oct/Nov 2019Paper 226 marks
Loading question…
Question text

6
Explain why constants, variables and arrays are used in programming.
Constants …
…
…
…
Variables …
…
…
…
Arrays …
…
…
…
[6]

122
2210/23/O/N/19 · Question 1Oct/Nov 2019Paper 2320 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers must have meaningful names.
Name two arrays you could use for Task 1. State the data type and purpose of each one.
Array 1 …
Data type 1 …
Purpose …
…
Array 2 …
Data type 2 …
Purpose …
…
[4]
(b) Name a variable that you used for Task 2. State the data type and purpose of this variable.
Explain why you chose to use a variable rather than a constant.
Variable …
Data type …
Purpose …
…
…
Reason for use of a variable …
…
…
[4]
(c) Write an algorithm for Task 1, using either pseudocode, programming statements or a
flowchart. Assume that the first part of Task 1, the storage and display of tile descriptions,
prices per box and identification codes has already been done.
…
…
…
…
…
…
…
…

123
2210/23/O/N/19 · Question 2Oct/Nov 2019Paper 232 marks
Loading question…
Question text

2
Describe the use of a subroutine in a program.
…
…
…
…
… [2]

Advertisement
124
2210/23/O/N/19 · Question 3Oct/Nov 2019Paper 233 marks
Loading question…
Question text

3
Name the three types of loop structure used in pseudocode.
…
…
…
…
…
… [3]

125
2210/23/O/N/19 · Question 4Oct/Nov 2019Paper 235 marks
Loading question…
Question text

4
The following pseudocode algorithm uses nested IF statements.
IF Response = 1
THEN
X + Y
X
ELSE
IF Response = 2
THEN
X – Y
X
ELSE
IF Response = 3
THEN
X * Y
X
ELSE
IF Response = 4
THEN
X / Y
X
ELSE
OUTPUT "No response"
ENDIF
ENDIF
ENDIF
ENDIF
(a) Name the type of statement demonstrated by the use of IF … THEN … ELSE … ENDIF
…
… [1]
(b) Re-write the pseudocode algorithm using a CASE statement.
…
…
…
…
…
…
…
…
…
… [4]

126
2210/23/O/N/19 · Question 5Oct/Nov 2019Paper 23146 marks
Loading question…
Question text

5
The algorithm performs an operation on the array named MyData
DIV means integer division, so only the whole number part of the result is returned
e.g. 7 DIV 2 returns a value of 3
0
First
16
Last
FALSE
Found
INPUT UserIn
WHILE (First <= Last) AND (Found = FALSE) DO
(First + Last) DIV 2
Middle
IF MyData[Middle] = UserIn
THEN
TRUE
Found
ELSE
IF UserIn < MyData[Middle]
THEN
Middle - 1
Last
ELSE
Middle + 1
First
ENDIF
ENDIF
ENDWHILE
OUTPUT Found
This table shows the contents of the array: MyData e.g. MyData[2] stores the value 5
MyData
Index [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]
Value
2
3
5
6
8 10 12 13 14 16 18
20
25
27
29
34
36
(a) Complete the trace table for the input data: 10
First
Last
UserIn
Middle
Found
OUTPUT
[6]
(b) Describe the function being performed by the algorithm.
…
…
…
… [2]

127
2210/21/M/J/19 · Question 1May/June 2019Paper 2120 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers must have meaningful names.
(i)
State one array you used for Task 1. State the data type and purpose of this array.
Array …
Data type …
Purpose …
…
…
[3]
(ii)
State one variable you used for Task 2 and one variable you used for Task 3. In each
case, state the data type and purpose of the variable.
Task 2 variable name …
Data type …
Purpose …
…
…
Task 3 variable name …
Data type …
Purpose …
…
…
[6]
(b) Write an algorithm to show how you calculated and output the number of late arrivals and the
average number of minutes late for each bus route (part of Task 2), using either pseudocode,
programming statements or a flowchart.
…
…
…
…
…
…
…
…
…
…

128
2210/21/M/J/19 · Question 2May/June 2019Paper 216 marks
Loading question…
Question text

2
Describe each of the following data types used in programming. In each case, give an example of
a piece of data to illustrate your answer. Each example must be different.
Char
…
…
…
String
…
…
…
Boolean
…
…
…
[6]

Advertisement
129
2210/21/M/J/19 · Question 4May/June 2019Paper 2111 marks
Loading question…
Question text

4
This section of program code may be used as a validation check.
1
PRINT "Input a value between 0 and 100 inclusive"
2
INPUT Value
3
WHILE Value < 0 OR Value > 100
4
PRINT "Invalid value, try again"
5
INPUT Value
6
ENDWHILE
7
PRINT "Accepted: ", Value
(a) Give a name for this type of validation check.
… [1]
(b) Describe what is happening in this validation check.
…
…
…
…
…
…
…
… [2]
(c) Complete the trace table for this program code using the test data: 200, 300, –1, 50, 60
Value
OUTPUT
[3]
(d) Draw a flowchart to represent this section of program code.
[5]

130
2210/22/M/J/19 · Question 1May/June 2019Paper 2220 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers must have meaningful names.
Describe the data structures you have used in Task 1 to record the items for sale. Include
some sample data for each data structure you have described.
…
…
…
…
…
…
…
…
…
…
… [5]
(b) Explain how your program for Task 1 ensures the item number is unique.
…
…
…
… [2]
(c) Write an algorithm for the part of Task 2 that allows the buyer to add a new bid, using
either pseudocode, programming statements or a flowchart. Assume that Task 1 has been
completed and that the item details have already been found.
…
…
…
…
…
…
…
…
…

131
2210/22/M/J/19 · Question 2May/June 2019Paper 228 marks
Loading question…
Question text

2
(a) An algorithm has been written in pseudocode to input 100 numbers, select and print the
largest number and smallest number.
1
Count
INPUT Number
Number
High
Count
Low
REPEAT
INPUT Number
IF Number > High
THEN
Number
High
ENDIF
IF Number > Low
THEN
Number
Low
ENDIF
Count + 1
Count
UNTIL Count > 99
PRINT "Largest Number is ", Number
PRINT "Smallest Number is ", Low
Find the four errors in the pseudocode and suggest a correction for each error.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
…
[4]
(b) Show how you would change the corrected algorithm to total the numbers and print the total.
Use a variable Total.
…
…
…
…
…
…
…
… [4]

132
2210/22/M/J/19 · Question 4May/June 2019Paper 224 marks
Loading question…
Question text

4
For each of the four groups of statements in the table, place a tick in the correct column to show
whether it is an example of Selection or Repetition.
Statements
Selection
Repetition
FOR A
1 TO 100
B + 1
B
NEXT A
CASE A OF
100: B
A
A
200: C
ENDCASE
IF A > 100
THEN
A
B
ENDIF
REPEAT
A
B * 10
UNTIL A > 100
[4]

133
2210/22/O/N/18 · Question 1Oct/Nov 2018Paper 2220 marks
Loading question…
Question text

1
(a) All variables, arrays, constants and other identifiers should have meaningful names.
(i)
State the name of one variable you have used for Task 3.
Give the data type for the variable. State what it is used for.
Variable name …
Data type …
Use …
[3]
(ii)
Describe the arrays that you have used to store the data for the children in Task 1.
Include the name, data type and its use for each array.
…
…
…
…
…
…
…
…
…
… [5]
(b) Explain how you ensured that each identification number entered in Task 1 was unique and
included a correct check digit.
…
…
…
…
…
…
…
… [4]
(c) Write an algorithm for Task 2, using either pseudocode, programming statements or a
flowchart. You should assume that Task 1 has already been completed.
…
…
…

Advertisement
134
2210/22/O/N/18 · Question 3Oct/Nov 2018Paper 223 marks
Loading question…
Question text

3
Four programming concepts and four descriptions are shown.
Draw a line to connect each programming concept to the most appropriate description.
Programming concept
Description
A subroutine that does not
Library routine
have to return a value.
Structure
A standard subroutine that is
diagram
available for immediate use.
A subroutine that always
Procedure
returns a value.
An overview of a program or
Function
subroutine.
[3]

135
2210/22/O/N/18 · Question 4Oct/Nov 2018Paper 224 marks
Loading question…
Question text

4
A programmer wants to test that the readings from 2000 electricity meters are greater than 400
units and less than 900 units. The programmer uses selection and repetition statements as part of
the program.
Explain, using programming statements, how selection and repetition could be used in this
program.
Selection …
…
…
…
…
Repetition …
…
…
…
…
…
…
…
[4]

Advertisement