Professional Documents
Culture Documents
Psuedocode Questions PRC
Psuedocode Questions PRC
1.
Write the pseudocode for calculating the commission of a salesman. The commission is calculated
according to the following rates:
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
3
__________________________________________________________________________________________
__________________________________________________________________________________________
b. Complete the table to show what output you would expect for the two inputs. [2]
Number Sum
11
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
__________________________________________________________________________________________
__________________________________________________________________________________________
6
b. Complete the following trace table for the input N as 4356 [4]
X N R S
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
__________________________________________________________________________________________
__________________________________________________________________________________________
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]
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
9
9. Read this section of program code that inputs 36 numbers(three digit numbers) and then outputs
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.
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
__________________________________________________________________________________________
10
b. The following table shows the elements in an array called Cars.
_____________________________________________________________________________
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.
_____________________________________________________________________________
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