Algorithm design and problem-solving – IGCSE Computer Science (0478)

200 questions · page 13 of 14

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
181
0478/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]

182
0478/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]

183
0478/22/O/N/17 · Question 5Oct/Nov 2017Paper 227 marks
Loading question…
Question text

5
(a) This flowchart checks a batch of 10 rice sacks for weight. Sacks should weigh 50 kilograms
each. Sacks weighing over 50.5 kilograms or less than 49.5 kilograms are rejected. The
number of sacks accepted and the number of sacks rejected is output.
START
Accept
0
Reject
0
Count
0
Yes
Is Count
= 10?
OUTPUT
Accept,
Accept
Accept + 1
No
Reject
Count
Count + 1
END
INPUT
Sack
Is Sack
Yes
Reject
Reject + 1
< 49.5?
No
Is Sack
> 50.5?
No
Yes
Complete the trace table for the input data:
50.4, 50.3, 49.1, 50.3, 50.0, 49.5, 50.2, 50.3, 50.5, 50.6
Accept
Reject
Count
Sack
OUTPUT
[5]
(b) The size of the batch has increased to 50 sacks. It has been decided to only reject sacks that
are underweight.
State the changes that need to be made to the flowchart.
…
…
…
… [2]

Advertisement
184
0478/21/M/J/17 · Question 2May/June 2017Paper 214 marks
Loading question…
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]

185
0478/21/M/J/17 · Question 3May/June 2017Paper 212 marks
Loading question…
Question text

3
A satellite navigation system works using destination details entered by the user, either a new
destination or chosen from previously saved destinations. The satellite navigation system will then
output directions to the destination in the form of either a visual map or a list of directions.
A satellite navigation system is an example of a computer system that is made up of sub-systems.
This structure diagram shows some of its sub-systems.
Complete the diagram by filling in the empty boxes.
Satellite navigation system
Input destination
Map
List
[2]

186
0478/21/M/J/17 · Question 4May/June 2017Paper 214 marks
Loading question…
Question text

4
For each of the four statements in the table, place a tick in the correct column to show whether it
is an example of validation or verification.
Statements
Validation
Verification
To automatically check the accuracy of a bar code
To check if the data input is sensible
To check if the data input matches the data that has been
supplied
To automatically check that all required data fields have been
completed
[4]

187
0478/21/M/J/17 · Question 5May/June 2017Paper 216 marks
Loading question…
Question text

5
(a) Describe the purpose of each statement in this algorithm.
1 TO 300
FOR I
INPUT Name[I]
NEXT I
…
…
…
…
… [2]
(b) Identify, using pseudocode, another loop structure that the algorithm in part (a) could have
used.
…
… [1]
(c) Write an algorithm, using pseudocode, to input a number between 0 and 100 inclusive. The
algorithm should prompt for the input and output an error message if the number is outside
this range.
…
…
…
…
…
…
…
…
…
… [3]

188
0478/21/M/J/17 · Question 6May/June 2017Paper 215 marks
Loading question…
Question text

6
This flowchart inputs a range of temperatures in degrees Fahrenheit.
As each temperature is input, it is compared with the previous highest temperature. If it is higher
than the current highest, it replaces the previous highest temperature and then it is converted to
degrees Celsius.
For ease of calculation, the final step of the Fahrenheit to Celsius conversion has been
approximated as division by 2.
When –1 is entered, the input process stops and the highest temperature (in both Fahrenheit and
Celsius) is output.
START
HighF
-100
HighC
-100
INPUT TempF
No
No
Is TempF
Is TempF
> HighF?
= -1?
Yes
Yes
HighF
TempF
HighC
(TempF-32)/2
OUTPUT 'The highest temperature is, ',
HighF, ' Fahrenheit, ',
HighC, ' Celsius.'
END
Complete the trace table for the input data:
68, 46, 50, 86, 65, 50, 40, 30, –1
HighF
HighC
TempF
OUTPUT
[5]

Advertisement
189
0478/22/M/J/17 · Question 2May/June 2017Paper 228 marks
Loading question…
Question text

2
(a) Write an algorithm to input three different numbers, and then output the largest number. Use
either pseudocode or a flowchart.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [4]
(b) Give two sets of test data to use with your algorithm in part (a) and explain why you chose
each set.
Test data set 1 …
Reason …
…
…
Test data set 2 …
Reason …
…
…
[4]

190
0478/22/M/J/17 · Question 3May/June 2017Paper 225 marks
Loading question…
Question text

3
This flowchart inputs the weight of items in kilograms to be loaded on a trailer. Any item over
25 kilograms is rejected. The trailer can take up to 100 kilograms.
START
TotalWeight
0
Reject
0
INPUT Weight
Yes
Is Weight
Reject
Reject + 1
˃ 25?
No
TotalWeight
TotalWeight + Weight
Is
No
TotalWeight
˃ 100?
Yes
TotalWeight
TotalWeight – Weight
OUTPUT 'Weight of items ' ’
TotalWeight, ' Number of
items rejected ',Reject
END
Complete the trace table for the input data:
13, 17, 26, 25, 5, 10, 15, 35, 20, 15
Weight
Reject
TotalWeight
OUTPUT
[5]

191
0478/22/F/M/17 · Question 1Feb/March 2017Paper 2220 marks
Loading question…
Question text

1
(a) All variables and other identifiers should have meaningful names.
(i)
Declare the array used to store the reaction times for the whole school.
… [1]
(ii)
Change this declaration so the array can only hold records for a sample of 50 students.
… [1]
(iii)
Explain why an array is an effective data structure for storing the reaction time records.
…
…
…
… [2]
(b) Write an algorithm to complete Task 1 for the whole school, using either pseudocode,
programming statements or a flowchart. DO NOT include any validation routines.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [3]
(c) Identify three different types of test data you used to test the validation checks on the age
input in Task 1. For each type, give an example of appropriate data.
Type of test data
Example data
[6]
(d) Explain how you calculated and outputted the average reaction time based on the user
inputs of age and school house, as part of Task 3. Any programming statements used in your
answer must be fully explaine

192
0478/22/F/M/17 · Question 3Feb/March 2017Paper 228 marks
Loading question…
Question text

3
There is a program that stores the following data:
•
EmployeeID, an employee ID which must be two letters followed by 4 numbers, e.g. TY4587
•
Manager, whether the employee is a manager or not
•
AnnualHoliday, number of whole days’ annual holiday
•
PayGrade, the employee’s pay grade which must be a single letter A–F
Complete the following table to identify:
•
The most appropriate data type for each variable
•
An appropriate validation check for each variable. You must use a different validation check
for each variable.
Variable
Data type
Appropriate validation check
EmployeeID
Manager
AnnualHoliday
PayGrade
[8]

193
0478/22/F/M/17 · Question 4Feb/March 2017Paper 224 marks
Loading question…
Question text

4
Study the flowchart.
START
INPUT A
OUTPUT B
IS
Yes
B
A
B
B + A
C
C – 1
A > 0 ?
C
A
No
IS
C <= 1 ?
OUTPUT
Yes
'Exit'
No
END
Complete the trace table for the input values 4, 3, −1:
A
B
C
OUTPUT
[4]

Advertisement
194
0478/21/O/N/16 · Question 3Oct/Nov 2016Paper 215 marks
Loading question…
Question text

3
The flowchart below inputs the price of an item under $10. The change from a $10 note is output.
Any amount less than 5 cents is rounded up to 5 cents.
The predefined function INT rounds a number down to the nearest whole number; for example
Z ← INT(5.7) gives the value Z = 5
START
INPUT Price
Change
10 – Price
Is
Yes
Change
Dollars
INT(Change)
>= 1?
No
Change
Change – INT(Change)
OUTPUT Dollars,
" dollars"
Is
Yes
Change
Change
Change – 0.5
>= 0.5?
No
OUTPUT "One 50
cent coin"
TenCents
INT(Change * 10 + 0.5)
OUTPUT TenCents,
" ten cent coins"
Is Change*10 –
OUTPUT "One 5
Yes
TenCents
cent coin"
> 0?
No
END
Complete the trace table for the input data: 6.29
Price
Change
Dollars
TenCents
OUTPUT
[5]

195
0478/21/O/N/16 · Question 4Oct/Nov 2016Paper 213 marks
Loading question…
Question text

4
Four validation checks and four descriptions are shown below.
Draw a line to link each validation check to the correct description.
Validation check
Description
Numbers between two
Presence check
given values are accepted
Data is of a particular
Range check
specified type
Data contains an exact
Type check
number of characters
Ensures that some data
Length check
have been entered
[3]

Advertisement