Comp Sci Algo8
Comp Sci Algo8
Comp Sci Algo8
Section B
2 Describe, giving an example for each, the following data types used in programming.
Integer
Description ........................................................................................................................................
..........................................................................................................................................................
Example ............................................................................................................................................
String
Description ........................................................................................................................................
..........................................................................................................................................................
Example ............................................................................................................................................
[4]
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
Totalling ............................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
[3]
1 Total = 100.00
2
PRINT ′Enter the height of each member of your class, one at a
time, when prompted′
3 FOR Count = 1 TO 30
4 PRINT ′Enter a height in metres′
5 INPUT Height
6 Total = Total + Height
7 PRINT Total / 30
8 Count = Count + 1
9 NEXT Count
State the line numbers that contain the errors and describe how to correct each error.
Error 1 .......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Error 2 .......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Error 3 .......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[1]
5 The algorithm allows a number to be entered. It then calculates and outputs the next number in
the mathematical series.
Fib 1
Prev2 0
Prev1 1
INPUT Number
IF Number = 0
THEN Fib 0
ENDIF
WHILE Number > 2
Fib Prev2 + Prev1
Prev2 Prev1
Prev1 Fib
Number Number - 1
ENDWHILE
OUTPUT Fib
[4]
[2]
6 An online fruit tree specialist sells fruit trees in various sizes. A database table, TREETAB, shows
the tree type and, for each size, the price and whether they are in stock.
(a) State whether any of the fields shown would be suitable as a primary key.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[2]
(b) Complete the table to show the most appropriate data type for each of the fields based on the
data shown in the table at the start of question 6.
Sort: Descending
Show:
Criteria: <10.00
or:
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[4]
(d) Using the following query-by-example grid, write a query to identify all types of the fruit trees
that are out of stock for all three sizes. Make sure the type of the tree and the various ‘in
stock’ fields are shown. The trees should be listed in alphabetical order by type.
Field:
Table:
Sort:
Show:
Criteria:
or:
[4]