Skip to content

Course home

Data types

Data types

Easy
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
Question 11

A programmer uses a record structure to store details about smart home appliances.

RECORD SmartDevice
    deviceName : String
    location : String
    wattsUsed : Integer
    isOn : Boolean
ENDRECORD

lamp ← SmartDevice('Desk Lamp', 'Bedroom', 15, True)
heater ← SmartDevice('Space Heater', 'Lounge', 1500, False)
router ← SmartDevice('Wi-Fi Router', 'Hallway', 12, True)
deviceList ← [lamp, heater, router]
maxWatts ← 0
targetIndex ← 0

FOR i ← 0 TO 2
    IF deviceList[i].wattsUsed > maxWatts THEN
        maxWatts ← deviceList[i].wattsUsed
        targetIndex ← i
    ENDIF
ENDFOR

OUTPUT deviceList[targetIndex].deviceName, ' uses the most power'

How many different values can the field isOn have?

A

222

B

888

C

256256256

D

Unlimited

Markscheme

Data types Questions

  1. GCSE
  2. /Computer Science
  3. /Data types

50 exam-style questions on AQA GCSE Computer Science Data types. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank