1 (a) Write an algorithm, using pseudocode, to input three different numbers, multiply the
two larger numbers together and output the result. Use the variables: Number 1,Number
2 and Number 3 for numbers and Answer for result.
.. REPEAT OUTPUT "Enter three different numbers" INPUT Number1,
Number2, Number3 UNTIL Number1 <> Number2 AND Number2 <>
Number3 AND Number3 <> Number1 IF Number3 < Number2 AND
Number3 < Number1 THEN Answer ← Number1 * Number2 ENDIF IF
Number2 < Number3 AND Number2 < Number1 THEN Answer ← Number1
* Number3 ENDIF IF Number1 < Number2 AND Number1 < Number3
THEN Answer ← Number2 * Number3 ENDIF OUTPUT "Answer = ",
Answer.........................................................................................................................................
........
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [5]
(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
777..........................................................................................................................
Reason . should be rejected as numbers are equal – abnormal test data
....................................................................................................................................
...................................................................................................................................................
Test data set - 7, 8, 9
Reason Normal test data should be accepted
[4]
2 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]
3 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]
11
4. 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 ......2.......................
Correct code ........... Counter =
0..................................................................................................................... Error 2 Line number
.............................
Correct code .....7.... Total = Total +
Number............................................................................................................................ Error 3
Line number ...........8..................
Correct code ....... Counter = Counter +
1.............................................................................................................................. Error 4 Line
number ......10.......................
Correctcode .. Average = Total /
Counter...................................................................................................................................
[4]
5. 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]
6. 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]
7. (a) Describe the purpose of each statement in this algorithm.
FOR I 1 TO 300
INPUT Name[I]
NEXT I
......For – To repeat 300 repetitions
I – used to store values consecutively as an array
Next – Input next
count .............................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
(b) Identify, using pseudocode, another loop structure that the algorithm in part (a) could have
used.
......................WHILE..DO...ENDWHILE........................................................................................
..................................
...............................................................................................................................................[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.
OUTPUT "Enter a number between 0 and 100 " INPUT Number IF
................
Number < 0 OR Number > 100 THEN OUTPUT "The number you have
entered is outside the specified range"
ENDIF...................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
8. 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. [5]
START
HighF-100
HighC-100
INPUT TempF
Is TempF No Is TempF No
= -1? > HighF?
Yes Yes
HighFTempF
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
9. Read this section of code that inputs the ages of people entering an event. The input sequence is
ended by inputting a negative value for age. The code outputs the number of people at the event
over the age of 18.
01 Num18 = 0
2 INPUT Age
3 WHILE Age >= 0 DO
4 IF Age >= 18 THEN
5 Num18 = Num18 + Age
6 ENDIF
7 ENDWHILE
8 PRINT Num18 - Age
There are four errors in this code.
Locate these errors and suggest code correction to remove each error.
Error 1 ...............................................................................................................................................
Correction..........................................................................................................................................
..........................................................................................................................................................
Error 2 ...............................................................................................................................................
Correction..........................................................................................................................................
..........................................................................................................................................................
Error 3 ...............................................................................................................................................
Correction..........................................................................................................................................
..........................................................................................................................................................
Error 4 ...............................................................................................................................................
Correction..........................................................................................................................................
..........................................................................................................................................................
[4]
10. Study the flowchart.
START
INPUT A OUTPUT B
IS A Yes A BB + A CC – 1
> 0 ? A
No
IS
OUTPUT C <= 1 ? Yes
'Exit'
No
END
Complete the trace table for the input values 4, 3, −1:
A B C OUTPUT
[5]
11 Explain the differences between a WHILE … DO … ENDWHILE and a REPEAT … UNTIL
loop.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[4]