Programming – O Level Computer Science (2210)

174 questions · page 10 of 12

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
136
2210/23/O/N/18 · Question 1Oct/Nov 2018Paper 2320 marks
Loading question…
Question text

1
(a) All arrays, variables, constants and other identifiers should have meaningful names.
(i)
State the name, data type and use of three arrays you have created for Task 1.
Array 1 name …
Data type …
Use …
…
Array 2 name …
Data type …
Use …
…
Array 3 name …
Data type …
Use …
…
[6]
(ii)
State the name, data type and use for one variable you used in Task 2.
Variable name …
Data type …
Use …
…
[2]
(b) Write an algorithm to show how your program finds and displays the weeks available for
each log cabin and its capacity (part of Task 2), using either pseudocode, programming
statements or a flowchart.
…
…
…
…
…
…
…
…
…
…

137
2210/23/O/N/18 · Question 2Oct/Nov 2018Paper 234 marks
Loading question…
Question text

2
Describe, giving an example for each, the following data types used in programming.
Integer
Description …
…
Example …
String
Description …
…
Example …
[4]

138
2210/23/O/N/18 · Question 3Oct/Nov 2018Paper 233 marks
Loading question…
Question text

3
Give an example of a pseudocode statement or statements to perform each of the following
functions.
A condition controlled loop …
…
…
A conditional statement …
…
…
Totalling …
…
…
[3]

Advertisement
139
2210/23/O/N/18 · Question 4Oct/Nov 2018Paper 234 marks
Loading question…
Question text

4
This is a section of program code.
1 Total = 100.00
2 PRINT ′Enter the height of each member of your class, one at a
time, when prompted′
3 FOR Count = 1 TO 30
4
PRINT ′Enter a height in metres′
5
INPUT Height
6
Total = Total + Height
7
PRINT Total / 30
8
Count = Count + 1
9 NEXT Count
(a) There are three errors in this code.
State the line numbers that contain the errors and describe how to correct each error.
Error 1 …
…
…
Error 2 …
…
…
Error 3 …
…
…
[3]
(b) State the purpose of this program.
…
…
… [1]

140
2210/23/O/N/18 · Question 5Oct/Nov 2018Paper 236 marks
Loading question…
Question text

5
The algorithm allows a number to be entered. It then calculates and outputs the next number in
the mathematical series.
1
Fib
0
Prev2
1
Prev1
INPUT Number
IF Number = 0
0
THEN Fib
ENDIF
WHILE Number > 2
Prev2 + Prev1
Fib
Prev1
Prev2
Fib
Prev1
Number - 1
Number
ENDWHILE
OUTPUT Fib
(a) Complete the trace table for the input data: 7
Fib
Prev2
Prev1
Number
OUTPUT
[4]
(b) Complete the trace table for the input data: 2
Fib
Prev2
Prev1
Number
OUTPUT
[2]

141
2210/21/M/J/18 · Question 1May/June 2018Paper 2120 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers should have meaningful names.
(i)
You recorded information for the estimate of the cost of building a computer in Task 1.
Give a data structure that you created for Task 1, its name, data type and use.
Data structure …
Name …
Data type …
Use …
…
[4]
(ii)
Describe the data structures that you have used in Task 2 to record the customer details.
Include sample data in the description.
…
…
…
…
…
…
…
… [4]
(b) Explain how your program for Task 1 produces a unique estimate number.
…
…
…
… [2]
(c) Write an algorithm for part of Task 2 to check that the chosen processor and chosen RAM
are in stock, using either pseudocode, programming statements or a flowchart. Assume that
Task 1 has been completed. Do not check the other components or produce the order.
…
…
…
…
…
…

142
2210/21/M/J/18 · Question 3May/June 2018Paper 218 marks
Loading question…
Question text

3
The global trade item number (GTIN-8) barcode has seven digits and a check digit.
This pseudocode algorithm inputs seven digits and calculates the eighth digit, then outputs the
GTIN-8.
DIV(X,Y), finds the number of divides in division for example DIV(23,10) is 2.
MOD(X,Y), finds the remainder in division for example MOD(23,10) is 3.
1 TO 7
FOR Count
INPUT Number
Number
Digit(Count)
NEXT
(Digit(1)+Digit(3)+Digit(5)+Digit(7))*3+Digit(2)+Digit(4)+Digit(6)
Sum
IF MOD(Sum,10) <> 0
DIV(Sum,10)*10 + 10 - Sum
THEN Digit(8)
0
ELSE Digit(8)
ENDIF
OUTPUT "GTIN-8"
1 TO 8
FOR Count
OUTPUT Digit(Count)
NEXT
(a) Complete the trace table for the input data: 5, 7, 0, 1, 2, 3, 4
Digit(1) Digit(2) Digit(3) Digit(4) Digit(5) Digit(6) Digit(7) Digit(8)
Sum
OUTPUT
Complete the trace table for the input data: 4, 3, 1, 0, 2, 3, 1
Digit(1) Digit(2) Digit(3) Digit(4) Digit(5) Digit(6) Digit(7) Digit(8)
Sum
OUTPUT
[5]
(b) Explain how you would change the algorithm to input eight digits (seven digits and the check
digit) and output if the check digit entered is correct or not.
…
…
…
…
…
…
… [3]
Question 4 starts on page 10.

143
2210/21/M/J/18 · Question 5May/June 2018Paper 214 marks
Loading question…
Question text

5
Explain the difference between the programming concepts of counting and totalling.
Include an example of a programming statement for each concept in your explanation.
…
…
…
…
…
…
…
…
… [4]

Advertisement
144
2210/22/M/J/18 · Question 1May/June 2018Paper 2220 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers should have meaningful names.
(i)
State the name, the data type and the use of two variables that you have used in Task 2.
Variable 1 name …
Data type …
Use …
Variable 2 name …
Data type …
Use …
[2]
(ii)
Describe, with the aid of some sample data, the data structures that you have used to
record the data for the cows in Task 1.
…
…
…
…
…
…
…
… [4]
(b) Explain how your program for Task 1 ensures that each 3-digit identity code is unique.
…
…
…
… [2]
(c) Write an algorithm for Task 2, using either pseudocode, programming statements or a
flowchart. Assume that Task 1 has been completed.
…
…
…
…
…
…
…

145
2210/22/M/J/18 · Question 3May/June 2018Paper 226 marks
Loading question…
Question text

3
This pseudocode algorithm inputs two non-zero numbers and a sign, and then performs the
calculation shown by the sign. An input of zero for the first number terminates the process.
INPUT
Number1, Number2, Sign
WHILE
Number1 <> 0
Number1 + Number2
ENDIF
IF
Sign = '+' THEN Answer
Number1 - Number2
ENDIF
IF
Sign = '-' THEN Answer
Number1 * Number2
ENDIF
IF
Sign = '*' THEN Answer
Number1 / Number2
ENDIF
IF
Sign = '/' THEN Answer
IF
Sign <> '/' AND Sign <> '*' AND Sign <> '-'
AND Sign <> '+'
0
THEN Answer
ENDIF
IF Answer <> 0 THEN OUTPUT Answer ENDIF
INPUT Number1, Number2, Sign
ENDWHILE
(a) Complete the trace table for the input data:
*
5, 7, +, 6, 2, –, 4, 3, , 7, 8, ?, 0, 0, /
Number1
Number2
Sign
Answer
OUTPUT
[3]
(b) Show how you could improve the algorithm written in pseudocode by writing an alternative
type of conditional statement in pseudocode.
…
…
…
…
…
…
…
…
…
… [3]

146
2210/22/O/N/17 · Question 1Oct/Nov 2017Paper 2220 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers should have meaningful names.
(i)
For one variable that you have used to record the information about a single boat in
Task 1, state the name, data type and its use.
Variable name …
Data type …
Use …
[3]
(ii)
State one constant and its value that you could have used for Task 1.
Constant name …
Value …
[2]
(b) Give two different validation checks you could have used for data entry in Task 1. For each
check explain why it could be used and provide a set of data for testing.
Validation check 1 …
…
Reason for choice …
…
Set of test data …
…
Validation check 2 …
…
Reason for choice …
…
Set of test data …
…
[6]
(c) Write an algorithm to complete Task 3, using either pseudocode, programming statements
or a flowchart. You may assume Task 2 has been completed.
…
…
…
…
…
…
…

147
2210/22/O/N/17 · Question 2Oct/Nov 2017Paper 226 marks
Loading question…
Question text

2
Write an algorithm using either pseudocode or a flowchart, to:
•
input a positive integer
•
use this value to set up how many other numbers are to be input
•
input these numbers
•
calculate and output the total and the average of these numbers.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]

148
2210/22/O/N/17 · Question 3Oct/Nov 2017Paper 223 marks
Loading question…
Question text

3
The following diagram shows four data structures and four descriptions.
Draw a line to connect each data structure to the correct description.
Data structure
Description
A collection of related data
Constant
A value that can change whilst a
Array
program is running
A value that never changes whilst a
Table
program is running
A series of elements of the same
Variable
data type
[3]

Advertisement
149
2210/22/O/N/17 · Question 4Oct/Nov 2017Paper 224 marks
Loading question…
Question text

4
IF … THEN … ELSE … ENDIF is one type of conditional statement used when writing
pseudocode.
Identify and describe another type of conditional statement that you could use when writing
pseudocode. Give a reason why you would use this type of conditional statement.
Conditional statement …
…
…
…
Description …
…
…
…
Reason …
…
[4]

150
2210/23/O/N/17 · Question 1Oct/Nov 2017Paper 2320 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers should have meaningful names.
(i)
Declare suitable arrays for each of the planes to store time slots booked.
…
…
… [3]
(ii)
Name one variable and one constant you used for Task 1 and state the purpose of each
one.
Variable …
Purpose …
…
Constant …
Purpose …
…
[4]
(b) Write an algorithm to complete Task 1, using either pseudocode, programming statements
or a flowchart.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
..

Advertisement