9608_s15_qp_32
A paper of Computer Science, 9608
Questions:
6
Year:
2015
Paper:
3
Variant:
2

Login to start this paper & get access to powerful tools

1
2
3
A particular programming language allows the programmer to define their own data types. ThisDate is an example of a user-defined structured data type. TYPE ThisDate DECLARE ThisDay : (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31) DECLARE ThisMonth : (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec) DECLARE ThisYear : INTEGER ENDTYPE A variable of this new type is declared as follows: DECLARE DateOfBirth : ThisDate Name the non-composite data type used in the ThisDay and ThisMonth declarations. Name the data type of ThisDate. The month value of DateOfBirth needs to be assigned to the variable MyMonthOfBirth. Write the required statement. Annual rainfall data from a number of locations are to be processed in a program. The following data are to be stored: • location name • height above sea level (to the nearest metre) • total rainfall for each month of the year (centimetres to 1 decimal place) A user-defined, composite data type is needed. The programmer chooses LocationRainfall as the name of this data type. A variable of this type can be used to store all the data for one particular location. Write the definition for the data type LocationRainfall. The programmer decides to store all the data in a file. Initially, data from 27 locations will be stored. More rainfall locations will be added over time and will never exceed 100. The programmer has to choose between two types of file organisation. The two types are serial and sequential. Give two reasons for choosing serial file organisation.
4
5
A gardener grows vegetables in a greenhouse. For the vegetables to grow well, the temperature needs to always be within a particular range. The gardener is not sure about the actual temperatures in the greenhouse during the growing season. The gardener installs some equipment. This records the temperature every hour during the growing season. Name the type of system described. Identify three items of hardware that would be needed to acquire and record the temperature data. Justify your choice for each. Item 1 Justification Item 2 Justification Item 3 Justification The equipment records temperatures in the greenhouse. It does this for seven locations. Each recording is stored as two successive bytes. The format is shown below: Greenhouse location Temperature reading Byte 1 Byte 2 The location is indicated by the setting of one of the seven bits in byte 1. For example, location 4 is indicated by setting bit 4. Bit 0 of byte 1 acts as a flag: • the initial value is zero • when the reading has been processed it is set to 1 Byte 2 contains the temperature reading (two’s complement integer). Interpret the data in byte 1 shown below: Byte 1 Byte 2 The system receives a temperature reading of –5 degrees from sensor 6. Complete the boxes below to show the two bytes for this recording. The reading has not yet been processed. Byte 1 Byte 2 The accumulator is loaded with the value of byte 1 from location 106. Write the assembly language instruction to check whether the reading in byte 2 came from location 4. LDD 106 // data loaded from address 106 Write the assembly language instruction to set the flag (bit 0) of the byte contained in the accumulator to 1.
6