Download as pdf or txt
Download as pdf or txt
You are on page 1of 120

PAPER – 2 QUESTIONS

1.
Write the pseudocode for calculating the commission of a salesman. The commission is calculated
according to the following rates:

Sale Commission Rate


30001 onwards 15%
22001 – 30000 10%
12000 – 22000 7%
5001 – 12000 3%
0 – 5000 0%

The sale made by the salesman is to be inputted and the calculated commission is to be displayed.

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

__________________________________________________________________________________ {5]

1
2. Study the following flowchart very carefully.

2
Start

sumß0
countß2

Input
number

Is count MOD
Yes sumß sum+count
2=0?

No

Yes
countß count+1

If count<=number
?

No

Print sum

Start

a. What does this algorithm do? [1]

3
__________________________________________________________________________________________

__________________________________________________________________________________________

b. Complete the table to show what output you would expect for the two inputs. [2]

Number Sum

11

3. The following pseudocode is to print the first 20 multiples of an inputted number.


Input number
For K = 1 to 19
num = num * K
Output num
Next number

There are three errors in the program. Locate these errors and suggest a correct piece
of code. [3]

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

4
4. Write an algorithm in the form of a flowchart which takes student heights in centimetres for 36
students and displays the number of students who have their heights more than 150 cm and those who
have their heights equal to or less than 150 cm. [4]

5
5. Study the below flowchart very carefully.

Start

Input N

X=N

S=0

N<>0 ? No Output S

Yes

R = N MOD 10 End

S = S*10 + R

N = N/10

a. What does this algorithm do? [1]

__________________________________________________________________________________________

__________________________________________________________________________________________

6
b. Complete the following trace table for the input N as 4356 [4]

X N R S

6. Study the following pseudocode very carefully.

Jß 1, SUMß0
COUNT ß0
INPUT N
WHILE COUNT < N
IF J%2 <> 0 THEN
SUM = SUM + J
COUNT = COUNT+1
ENDIF
J=J+1
ENDWHILE
OUTPUT SUM

a. What does this algorithm do? [1]

__________________________________________________________________________________________

__________________________________________________________________________________________

b. Complete the table to show what output you would expect for the two inputs. [2]

N Sum

7
7. Study the following flowchart very carefully.

8
Complete the trace table for the following data: [5]

8. Write an algorithm, using pseudocode which: [3]


• inputs three numbers
• outputs the largest of the three numbers

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

9
9. Read this section of program code that inputs 36 numbers(three digit numbers) and then outputs

the smallest number. [3]

Hß999
Cß0
Repeat
Read X
If X<H then XßH
CßC+1
Print H
Until C<36

There are three errors in this code. Locate these errors and suggest a correct piece of code

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

10.

a. Explain what is meant by an array. [1]

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

10
b. The following table shows the elements in an array called Cars.

What is the value of Cars [3]? [1]

_____________________________________________________________________________

c. Write an algorithm in the form of pseudocode to read in 100 numbers and store in
the array NUM. [2]

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

11. An airport has a number of hotels nearby. A database has been set up to give customers
information to allow them to select a hotel.

Hotel Name of No. of No. of Hotel Price per Distance from


Ref hotel stars rooms parking person ($) airport (km)
H21 Capri by Fraser 5 150 Y 200 2
K67 Grand Mercure Roxy 4 65 Y 85 5
N30 Park Avenue 3 38 N 60 8
H18 The fragrance hotel 5 165 Y 150 3
L56 The Village hotel 2 15 N 50 9
L34 Hotel 81- Tristar 2 24 N 45 11
N22 Venue Hotel 3 40 Y 65 6
N61 Best Hotel 3 45 N 55 10

a. Which field in each record must be unique? [1]

_____________________________________________________________________________

b. The following search condition was typed in :

11
(No. of stars > 3) OR (Hotel Parking = Y)
Using Hotel Ref only, which records would be found? [2]

__________________________________________________________________________________

__________________________________________________________________________________

c. Write down the search condition to find which hotels were less than 10 km from the airport and charged
under $100 per person. [2]

__________________________________________________________________________________

__________________________________________________________________________________

d. The database was sorted into descending order using No. of rooms. Using Hotel Ref only; write down
the sorted order of records. [2]

__________________________________________________________________________________

__________________________________________________________________________________

__________________________________________________________________________________

__________________________________________________________________________________

12.

12
13.

13
14.

14
15
16
15.

16.

17
17.

18
19
18.

20
21
19.

20.

22
23
21.

24
22.

25
26
23.

27
24.

28
29
25.

30
31
26.

32
27.

33
28.

34
29.

35
30.

36
31.

37
32.

33.

38
39
34.

40
35.

41
42
36.

43
37.

44
45
38.

46
47
39.

40.
48
.

49
50
41.

51
42.

52
53
43.

54
55
44.

56
45.

57
46.

58
59
47.

48.

60
61
49.

62
63
50.

64
51.

52.

65
53.

66
67
54.

68
69
70
55.

71
56.

72
57.

73
74
58.

75
76
59.

77
60.

78
61.

79
80
62.

81
82
63.

83
64.

84
85
65.

86
66.

87
67.

88
89
68.

69.

90
91
70.

92
93
71.

94
95
96
72.

97
98
73.

99
74.

75.

100
.

101
76.

102
103
77.

104
78.

105
106
79.

107
108
80.

109
81.

110
111
82.

112
83.

113
84.

114
115
85.

116
117
86.

118
119
87.

Ref: http://www.cie.org.uk/
Compiled by: Roshni Sabarinath
I.T. Department, GIIS, Queenstown

120

You might also like