9608_s17_qp_32
A paper of Computer Science, 9608
Questions:
6
Year:
2017
Paper:
3
Variant:
2

Login to start this paper & get access to powerful tools

1
Consider the following pseudocode user-defined data type: TYPE MyContactDetail DECLARE Name : STRING DECLARE HouseNumber : INTEGER ENDTYPE Write a pseudocode statement to declare a variable, NewFriend, of type MyContactDetail. Write a pseudocode statement that assigns 129 to the HouseNumber of NewFriend. The user-defined data type MyContactDetail needs to be modified by: • adding a field called Area which can take three values, uptown, downtown or midtown • amending the field HouseNumber so that house numbers can only be in the range 1 to 499. Write the updated version of MyContactDetail. A pointer is a variable that stores the address of a variable of a particular type. Consider the pseudocode on page 3, which uses the following identifiers: Identifier Data type Description IPointer ^INTEGER pointer to an integer Sum INTEGER an integer variable MyInt1 INTEGER an integer variable MyInt2 INTEGER an integer variable Sum // assigns the value 91 to the integer variable Sum IPointer @Sum // assigns to IPointer the address of the // integer variable Sum MyInt1 IPointer^ // assigns to variable MyInt1 the value at an // address pointed at by IPointer IPointer^ MyInt2 // assigns the value in the variable MyInt2 to // the memory location pointed at by IPointer The four assignment statements are executed. The diagram shows the memory contents after execution. Variable Memory Address Contents . . . IPointer . . . Sum . . . MyInt1 MyInt2 . . . Use the diagram to state the current values of the following expressions: IPointer IPointer^ @MyInt1 IPointer^ = MyInt2 Write pseudocode statements that will achieve the following: Place the address of MyInt2 in IPointer. Assign the value 33 to the variable MyInt1. Copy the value in MyInt2 into the memory location currently pointed at by IPointer.
2
3
4
5
6
A large office building has many floors. On each floor there are security sensors and security cameras. There is the same number of sensors on each floor. The building has a single security room. The images from the security cameras are output on monitors (one monitor for each floor) placed in the security room. The data from the sensors are read and processed by a computer system. Sensor readings and warning messages can be displayed on the monitors. State the name given to the type of system described. Explain your answer to part . State two sensors that could be used in this system. Sensor 1 Sensor 2 A software routine: • checks the readings from the sensors • outputs readings and warning messages to the monitors • loops continuously. The routine uses the following pseudocode variables: Identifier Data type Description FloorCounter INTEGER Loop counter for number of floors SensorCounter INTEGER Loop counter for number of sensors NumberOfFloors INTEGER Stores the number of floors NumberOfSensors INTEGER Stores the number of sensors ForEver BOOLEAN Stores value that ensures continuous loop Complete the following pseudocode algorithm for the routine. 01 ForEver 02 REPEAT 03 FOR FloorCounter 1 TO NumberOfFloors 04 FOR SensorCounter 1 TO 05 READ Sensor(SensorCounter)on Floor(FloorCounter) 06 IF Sensor value outside range 07 THEN 08 OUTPUT “Problem on Floor ”, FloorCounter 09 ENDIF 10 ENDFOR 11 ENDFOR 12 // 13 // Delay loop 14 // Delay loop 15 // 16 UNTIL A delay needs to be introduced before the loop is processed again. Write a FOR loop, in pseudocode, to replace lines 13 and 14. Give a reason for this delay in the system. An alternative method of reading and processing sensor data is to use interrupts. Each sensor is connected so that it can send an interrupt signal to the processor if its value changes. On receipt of an interrupt signal, the processor carries out a number of steps as shown in the following diagram. Interrupt 1. Disable interrupts Return to task 6. Enable interrupts 2. Save current task 3. Identify source of interrupt 4. Jump to Interrupt Service Routine 5. Restore task State the purpose of step 3. Explain what happens at step 4.