Programming – IGCSE Computer Science (0478)
282 questions · page 17 of 19
Question text
3
This section of program code reads the contents of the array, totals the numbers and prints out the
sum and average of the numbers. Assume the array is full.
Complete the four missing items by writing them in the spaces provided in this code.
1
Numbers[1:30]
2
Total = 0
… = 0
3
FOR Count = 1 TO …
4
5
Number = Numbers[Count]
Total = … + Number
6
7
Counter = Counter + 1
… Count
8
9
PRINT ′The sum of the numbers you entered is ′, Number
10 PRINT ′The average of the numbers you entered is ′, Number / Counter
[4]
Question text
13 State four functions of an operating system.
Function 1 …
…
Function 2 …
…
Function 3 …
…
Function 4 …
…
[4]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Question text
1
(a) All identifiers should have meaningful names.
(i)
State the name and data structure that you have used to record student names in Task 1.
Name …
Data structure …
[2]
(ii)
State the name of one constant and the name of one variable that you could have used
in your programmed solution.
State the value that would be assigned to the constant. State the data type for the
variable. Explain what each one would be used for in your programmed solution.
Constant name …
Value …
Use …
…
Variable name …
Data type …
Use …
…
[6]
(b) Explain how you would change your program for Task 2 if the maximum group size for each
subject is increased to 25.
…
…
…
…
…
… [2]
(c) Write an algorithm to complete Task 1, using either pseudocode, programming statements
or a flowchart.
…
…
…
…
…
…
…
…
Question text
2
An algorithm has been written in pseudocode to input some numbers and print out any numbers
that are greater than or equal to 100. The number 999 stops the algorithm.
INPUT Number
WHILE NUMBERS <> 999 DO
IF Number > 100 THEN PRINT Number ENDIF
ENDWHILE
PRINT Number
(a) Find the four errors in the pseudocode and suggest corrections.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
…
[4]
(b) Show, using pseudocode, how you would change the corrected algorithm to print out any
numbers between 100 and 200 inclusive.
…
…
…
…
…
…
…
… [2]
Question text
5
Explain the difference between the programming concepts of sequence and selection. Include
an example of a programming statement for each concept in your explanation.
…
…
…
…
…
…
…
…
… [4]
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.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
..
Question text
2
This section of program code asks for 80 numbers between 100 and 1000 to be entered. It checks
that the numbers are in the correct range, and stores them in an array. It counts how many of the
numbers are larger than 500 and then outputs the result when the program is finished.
1 Count = 0
2 FOR Index = 1 TO 80
3
INPUT 'Enter a number between 100 and 1000', Number
4
WHILE Number = 99 AND Number = 1001
5
INPUT 'This is incorrect, please try again', Number
6
ENDWHILE
7
Num[80] = Number
8
IF Number > 500 THEN Count = Count + 1
9 UNTIL Index = 80
10 PRINT Index
11 PRINT ' numbers were larger than 500'
There are four lines of code that contain errors.
State the line number for each error and write the correct code for that line.
Error 1 Line Number …
Correct Code …
Error 2 Line Number …
Correct Code …
Error 3 Line Number …
Correct Code …
Error 4 Line Number …
Correct Code …
[4]
Question text
4
(a) Four pseudocode descriptions and five pseudocode statements are shown. Draw one line to
link each pseudocode description to the correct pseudocode statement. Not all pseudocode
statements will be used.
Pseudocode description
Pseudocode statement
A loop that will iterate at least
once.
FOR…TO…NEXT
A conditional statement to deal
IF…THEN…ELSE…ENDIF
with many possible outcomes.
WHILE…DO…ENDWHILE
A loop that will iterate a set
number of times.
CASE…OF…OTHERWISE…ENDCASE
REPEAT…UNTIL
A conditional statement with
different outcomes for true
and false.
[4]
(b) Write an algorithm in pseudocode, using a single loop, to print 50 names that have been
stored in an array.
…
…
…
…
…
…
…
…
…
… [3]
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.
…
…
…
…
…
…
…
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]
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]
Question text
11
State three functions provided by an operating system.
Function 1 …
…
…
Function 2 …
…
…
Function 3 …
…
…
[3]
Question text
9
A cold store is kept at a constant low temperature using a sensor, a microprocessor and a cooling
unit.
Explain how the sensor and microprocessor will maintain a constant low temperature.
����������������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������������������������������������������������������������������
������������������������������������������������������������������������������������������������������������������������������������������������������[6]
Question text
1
(a) All variables, constants and other identifiers should have meaningful names.
(i)
Name two constants you used for Task 1 and state the value of each one.
Constant 1 …
Value …
Constant 2 …
Value …
[2]
(ii)
Name two arrays you used for Task 2 and state the purpose of each one.
Array 1 …
Purpose …
…
Array 2 …
Purpose …
…
[2]
(b) Write an algorithm to complete Task 1, using either pseudocode, programming statements
or a flowchart.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
2
This section of program code asks for 50 numbers to be entered. The total and average of the
numbers are calculated.
1
Total = 0
2
Counter = 50
3
PRINT ′When prompted, enter 50 numbers, one at a time′
4
REPEAT
5
PRINT ′Enter a number′
6
INPUT Number
7
Total + Number = Total
8
Number = Number + 1
9
UNTIL Counter = 50
10
Average = Number * Counter
11
PRINT ′The average of the numbers you entered is ′, Average
There are four errors in this code.
State the line number for each error and write the correct code for that line.
Error 1 Line number …
Correct code …
Error 2 Line number …
Correct code …
Error 3 Line number …
Correct code …
Error 4 Line number …
Correct code …
[4]