3.1. Data representation
A subsection of Computer Science, 9608, through 3. Advanced Theory
Listing 10 of 43 questions
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.
9608_s15_qp_31
THEORY
2015
Paper 3, Variant 1
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.
9608_s15_qp_32
THEORY
2015
Paper 3, Variant 2
Questions Discovered
43