0% found this document useful (0 votes)
86 views4 pages

Cie CS CH7 2

The pseudocode algorithm inputs 100 numbers, selects the largest and smallest numbers, and prints them. There are 4 errors in the pseudocode. The algorithm can be changed to total the numbers input and print the total by adding a variable called Total, initializing it, and updating it in each iteration to keep a running total. A flowchart is given that inputs marks until -1 is entered, totals the marks, counts them, and tracks distinctions. It can be traced using a sample data set. Statements are classified as using selection or repetition. Validation checks data meets criteria while verification ensures the system meets requirements.

Uploaded by

Giga Chad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views4 pages

Cie CS CH7 2

The pseudocode algorithm inputs 100 numbers, selects the largest and smallest numbers, and prints them. There are 4 errors in the pseudocode. The algorithm can be changed to total the numbers input and print the total by adding a variable called Total, initializing it, and updating it in each iteration to keep a running total. A flowchart is given that inputs marks until -1 is entered, totals the marks, counts them, and tracks distinctions. It can be traced using a sample data set. Statements are classified as using selection or repetition. Validation checks data meets criteria while verification ensures the system meets requirements.

Uploaded by

Giga Chad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

8

Section B

2 (a) An algorithm has been written in pseudocode to input 100 numbers, select and print the
largest number and smallest number.

Count 1
INPUT Number
High Number
Low Count Low <- Number
REPEAT
INPUT Number
IF Number > High
THEN
High Number
ENDIF
IF Number > Low Number < Low
THEN
Low Number
ENDIF
Count Count + 1
UNTIL Count > 99 Count = 100
PRINT "Largest Number is ", Number High
PRINT "Smallest Number is ", Low

Find the four errors in the pseudocode and suggest a correction for each error.

Error 1 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 ........................................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................
[4]

© UCLES 2019 0478/22/M/J/19


9

(b) Show how you would change the corrected algorithm to total the numbers and print the total.
Use a variable Total.

...................................................................................................................................................
Total <- Number
Total + Number
...................................................................................................................................................

...................................................................................................................................................
PRINT " Total is" , Total

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

© UCLES 2019 0478/22/M/J/19 [Turn over


10

3 This flowchart inputs the marks gained in an examination. An input of –1 ends the routine.

START

Total 0
Count 0
Distinction 0

INPUT Mark

Is Mark = –1 ? Yes
Total Total + Mark
Count Count + 1

No

No Is OUTPUT "Number of
Mark >= Distinctions ", Distinction
80 ? OUTPUT "Average Mark "
Total/Count
Yes

Distinction Distinction + 1 END

Complete the trace table for the mark input data: 50, 70, 65, 30, 95, 50, 55, 85, 65, 35, –1, 45

Total Count Distinction Mark OUTPUT


0 0 0 50
50 1 0 70
120 2 0 65
185 3 0 30
215 4 0 95
310 5 1 50
360 6 55
415 7 85
500 8 1 65
565 9 35
600 10 -1 Number of Distinctions 2
Average Mark 60
[4]
© UCLES 2019 0478/22/M/J/19
11

4 For each of the four groups of statements in the table, place a tick in the correct column to show
whether it is an example of Selection or Repetition.

Statements Selection Repetition


FOR A 1 TO 100
B B + 1 /
NEXT A
CASE A OF
100: B A /
200: C A
ENDCASE
IF A > 100
THEN
B A /
ENDIF
REPEAT
A B * 10 /
UNTIL A > 100
[4]

5 Explain what is meant by validation and verification.


Give an example for each one.

Validation ..........................................................................................................................................

..........................................................................................................................................................
automated checking
checking that data is reasonable / of a certain type
..........................................................................................................................................................
checking that data meets certain criteria
..........................................................................................................................................................

Example ...........................................................................................................................................
range check, length check, type check, check digit
..........................................................................................................................................................

..........................................................................................................................................................

Verification ........................................................................................................................................
checking that data has not changed
..........................................................................................................................................................
during input to a computer
..........................................................................................................................................................
during transfer between computer devices
..........................................................................................................................................................

Example ...........................................................................................................................................
double entry, checking against original , visual check
..........................................................................................................................................................

..........................................................................................................................................................
[6]

© UCLES 2019 0478/22/M/J/19 [Turn over

You might also like