0% found this document useful (0 votes)
26 views9 pages

Paper Ii - Test

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)
26 views9 pages

Paper Ii - Test

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/ 9

1.

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.

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

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

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

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

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

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

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

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

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

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

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

2.
3

4. A routine checks the weight of melons to be sold in a supermarket. Melons weighing under 0.5 kilograms
are rejected and melons weighing over 2 kilograms are also rejected. Give an example of each type of test
data for this routine.
Normal .............................................................................................................................................
Extreme ............................................................................................................................................
Abnormal ......................................................................................................................................[3]

Identify two different conditional statements that you can use when writing pseudocode.
.......................................................................................................................................................
...................................................................................................................................................[2]
5

Section B

1 Read this section of program code that should input 30 positive numbers and then output the
largest number input.

1 Large = 9999

2 Counter = 0

3 WHILE Counter > 30

4 DO

5 INPUT Num

6 IF Num < Large THEN Large = Num

7 Counter = Counter - 1

8 ENDWHILE

9 PRINT Large

There are four errors in this code.

Locate these errors and suggest a corrected piece of code for each error.

1 .......................................................................................................................................................

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

2 .......................................................................................................................................................

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

3 .......................................................................................................................................................

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

4 .......................................................................................................................................................

......................................................................................................................................................[4]
3 (a) The flowchart below inputs six single digit numbers. The predefined function MOD gives the
value of the remainder, for example, Y  10 MOD 3 gives the value Y = 1

START

INPUT
A, B, C, D, E, F

Total  A*1 + B*2 + C*3 + D*4 + E*5

Check  Total MOD 11

Is Check = Yes OUTPUT


F? 'Accept'

No

OUTPUT
'Reject'

END
7

Complete a trace table for each of the two sets of input data.

Set 1 5, 2, 4, 3, 1, 5

Set 2 3, 2, 1, 0, 7, 3

Trace table set 1 5, 2, 4, 3, 1, 5

A B C D E F Total Check Output

Trace table set 2 3, 2, 1, 0, 7, 3

A B C D E F Total Check Output

[4]

(b) State the purpose of the flowchart in part (a).

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

...............................................................................................................................................[1]

(c) Identify a problem with this flowchart and explain how to correct it.

Problem ....................................................................................................................................

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

Solution .....................................................................................................................................

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

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

...............................................................................................................................................[3]
4 Four programming concepts and four examples of programming code are shown below.

Draw a line to link each programming concept to the correct example of programming code.

Programming
Example of programming code
concept

Counting Sum = Sum + Value[n]

Repetition IF Value = 10 THEN PRINT 'X'

Selection FOR Counter = 1 TO 10

Totalling Amount = Amount + 1

Sum = Num1 + Num2


[4]

5 (a) Write an algorithm, using pseudocode and a FOR … TO … NEXT loop structure, to input
1000 numbers into an array.

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

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

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

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

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

...............................................................................................................................................[2]

(b) Rewrite your algorithm using another loop structure.

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

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

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

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

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

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

...............................................................................................................................................[4]
12
13

You might also like