Data Types (AQA GCSE Computer Science)

Exam Questions

6 mins4 questions
11 mark

The algorithm in Figure 2 has been developed to automate the quantity of dog box biscuits to put in a dog bowl at certain times of the day.

Figure 2

1 time  USERINPUT
2 IF time = 'breakfast' THEN
3    q  1
4 ELSE IF time = 'lunch' THEN
5    q  4
6 ELSE IF time = 'dinner' THEN
7    q  2
8 ELSE
9    OUTPUT 'time not recognised'
10 ENDIF
11 FOR n  1 TO q
12     IF n < 3 THEN
13        DISPENSE_BISCUIT('chewies')
14     ELSE
15        DISPENSE_BISCUIT('crunchy')
16     ENDIF
17 ENDFOR

Select one choice which shows the data type of the variable time in the algorithm shown in Figure 2.

  • Date/Time

  • String

  • Integer

  • Real

Did this page help you?

21 mark

The algorithm in Figure 4 is a sorting algorithm

  • Array indexing starts at 0.

  • Line numbers are included but are not part of the algorithm

Figure 4

1 arr  [4, 1, 6]
2 swapsMade  false
3 WHILE swapsMade = false
4     swapsMade  true
5     i  0
6     WHILE i < 2
7        IF arr[i+1] < arr[i] THEN
8           t  arr[i]
9           arr[i]  arr[i+1]
10          arr[i+1]  t
11          swapsMade false
12        ENDIF
13        i  i + 1
14      ENDWHILE
15 ENDWHILE

State the data type of the variable swapsMade in the algorithm shown in Figure 4.

Did this page help you?

3a2 marks

Figure 3 box shows an algorithm, represented using pseudocode, that calculates the delivery cost for an order from a takeaway company.

Figure 3

orderTotal  USERINPUT
deliveryDistance  USERINPUT
deliveryCost  0.0
messageOne  "Minimum spend not met"
messageTwo  "Delivery not possible"
IF deliveryDistance ≤ 5 AND orderTotal > 0.0 THEN
    IF orderTotal > 50.0 THEN
       deliveryCost  1.5
       OUTPUT deliveryCost
    ELSE IF orderTotal > 25.0 THEN
       deliveryCost  (orderTotal / 10) * 2
       OUTPUT deliveryCost
    ELSE
       OUTPUT messageOne
    ENDIF
ELSE
     OUTPUT messageTwo
ENDIF

State the most suitable data type for the following variables used in Figure 3.

Variable identifier

Data type

deliveryCost

messageOne

3b1 mark

State one other common data type that you have not given in your answer to the above question.

Did this page help you?

41 mark

The algorithm shown in Figure 1 is designed to help an athlete with their training. It uses two subroutines getBPM and wait:

  • getBPM() returns the athlete’s heart rate in beats per minute from an external input device

  • wait(n) pauses the execution of the algorithm for n seconds, so wait(60) would pause the algorithm for 60 seconds.

Line numbers have been included but are not part of the algorithm

Figure 1

1 seconds ← 0
2 rest ← 50
3 REPEAT
4   bpm ← getBPM()
5   effort ← bpm – rest
6   IF effort ≤ 30 THEN
7      OUTPUT 'faster'
8   ELSE
9      IF effort ≤ 50 THEN
10       OUTPUT 'steady'
11     ELSE
12       OUTPUT 'slower'
13     ENDIF
14   ENDIF
15   wait(60)
16   seconds ← seconds + 60
17 UNTIL seconds > 200

State the most appropriate data type of the variable seconds in the algorithm shown in Figure 1.

Did this page help you?