
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















© UCLES 2016 0478/21/M/J/
Section B 2 Read this section of program code that inputs 10 positive numbers and then outputs the smallest number input. 1 Small = 1000 2 Counter = 0 3 REPEAT 4 INPUT Num 5 IF Num < Small THEN Small = Num 6 Counter = Counter + 1 7 UNTIL Counter = 10 8 PRINT Small (i) Identify three changes you would need to make to find the largest number input instead of the smallest number. 1 ......................................................................................................................................... ........................................................................................................................................... 2 ......................................................................................................................................... ........................................................................................................................................... 3 ......................................................................................................................................... .......................................................................................................................................[3] (ii) Rewrite the program code with your changes. ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... .......................................................................................................................................[3]
© UCLES 2016 0478/21/M/J/16 [Turn over
3 A program will be written to store information about members of a swimming club. The following membership details will be recorded:
© UCLES 2016 0478/21/M/J/16 [Turn over
Complete the trace table for the input data: 1.4, 1.3, 1.1, 1.3, 1.0, 1.5, 1.2, 1.3, 1.4, 1.3, 0.9, 1.5, 1.6, 1. Riders Reject Height OUTPUT
© UCLES 2016 0478/21/M/J/
5 REPEAT ... UNTIL is one type of loop structure. Identify and describe two other types of loop structure that you could use when writing pseudocode. Loop structure 1 ......................................................................................................................... Description ................................................................................................................................. ................................................................................................................................................... Loop structure 2 ......................................................................................................................... Description ................................................................................................................................. ...............................................................................................................................................[4]
© UCLES 2016 0478/22/M/J/
4 Four statement types and four examples are shown below. Draw a line to connect each statement type to the correct example. Statement type Example Assignment FOR X 1 TO 10
Iteration READ^ X
Input PRINT^ X
Output X^ Y^ +^ Z [3]
5 A programmer writes a program to store a patient’s temperature every hour for a day. State the data structure that would be most suitable to use and give the reason for your choice. Data structure ................................................................................................................................... Reason .............................................................................................................................................. ......................................................................................................................................................[2]
6 Identify two different selection statements that you can use when writing pseudocode. 1 ........................................................................................................................................................ .......................................................................................................................................................... 2 ........................................................................................................................................................ ......................................................................................................................................................[2]
© UCLES 2016 0478/22/M/J/16 [Turn over
Question 7 begins on page 10.
©UCLES 2017 0478/22/M/J/
4 An algorithm has been written in pseudocode to input 100 numbers and print out the sum. A REPEAT … UNTIL loop has been used. Count ← 0 Sum ← 0 REPEAT INPUT Number Sum ← Sum + Number Count ← Count + 1 UNTIL Count > 100 PRINT Sum (a) Find the error in the pseudocode and suggest a correction. Error ........................................................................................................................................... Correction ................................................................................................................................. ................................................................................................................................................... [2] (b) Rewrite the correct algorithm using a more suitable loop structure. ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ...............................................................................................................................................[3]
©UCLES 2020 0478/21/M/J/20 [Turn over
4 The pseudocode algorithm shown should allow numbers to be entered and should allow 50 numbers to be stored in an array.
INPUT Values[Count]
UNTIL Count = 0 (a) Explain why the algorithm will never end. ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ............................................................................................................................................. [2] (b) Re-write the original pseudocode so that it terminates correctly and also prevents numbers below 100 from being stored in the array Values[ ] ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ............................................................................................................................................. [4] (c) Describe how you could change your pseudocode in part (b) so that it prevents numbers below 100 and above 200 from being stored in the array Values[ ] ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ............................................................................................................................................. [2]
©UCLES 2020 0478/22/M/J/20 [Turn over
(b) Explain how you could extend the algorithm to also find the lowest mark awarded, count the number of students with that mark, and output both these values. ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ............................................................................................................................................. [6]
©UCLES 2020 0478/23/M/J/20 [Turn over
3 This section of pseudocode is to be used as a validation check that will continue until a number between 0 and 499 inclusive is entered. 1 PRINT "Input a number from 0 to 499 inclusive" 2 FOR Number 1 TO 10 3 INPUT Number 4 IF Number < 0 AND Number > 499 5 THEN 6 PRINT "Invalid number, please try again" 7 ENDIF 8 UNTIL Number = 0 OR Number = 499 9 PRINT Number, " is within the correct range" There are three lines in this pseudocode that contain errors. In each case, state the line number to identify the incorrect line and write out the corrected line in full. Error 1 line number .......................................................................................................................... Correction ......................................................................................................................................... .......................................................................................................................................................... Error 2 line number .......................................................................................................................... Correction ......................................................................................................................................... .......................................................................................................................................................... Error 3 line number .......................................................................................................................... Correction ......................................................................................................................................... .......................................................................................................................................................... [6]
© UCLES 2016 0478/22/O/N/
4 IF ... THEN ... ELSE ... ENDIF and CASE ... OF ... OTHERWISE ... ENDCASE are two different conditional statements that you can use when writing pseudocode. Explain, using examples, why you would choose to use each conditional statement. Example 1 ........................................................................................................................................ .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... Reason for choice ............................................................................................................................ .......................................................................................................................................................... .......................................................................................................................................................... Example 2 ........................................................................................................................................ .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... Reason for choice ............................................................................................................................ .......................................................................................................................................................... ..................................................................................................................................................... [6]
© UCLES 2016 0478/22/O/N/16 [Turn over
Question 5 begins on page 10.
©UCLES 2017 0478/21/O/N/17 [Turn over
(b) Write an algorithm in pseudocode, using a single loop, to print 50 names that have been stored in an array. ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ...............................................................................................................................................[3]
©UCLES 2017 0478/22/O/N/17 [Turn over
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 Constant A collection of related data
Array A value that can change whilst aprogram is running
Table A value that never changes whilst aprogram is running
Variable A series of elements of the samedata type [3]
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]