You are on page 1of 1

Student Name: Javan Smith

Class: 4-ARTS

Activity 3 (15 Marks)


Section II: Trace and Truth Table

1. Using the following algorithm, complete a copy of the trace table given that X = 4. Note that the first row
has been done for you. (9 marks)

Read X
For M = 1 to X do
Y=X–M
Z=5*Y–M
EndFor
Stop

X M Y Z

4 1 3 14

4 2 2 8

4 3 1 2

4 4 0 -4

(b) What kind of Loop is used in the above algorithm? (2 marks)


For Loop

2. A room is monitored by a temperature sensor and a smoke sensor. These sensors are connected to
an alarm. If the temperature is too high, the alarm is sounded. If smoke is detected, then the alarm is
sounded.

Suppose:
High temperature or presence of smoke is represented by 1
Normal temperature or no smoke is represented by 0
Sounding the alarm is represented by 1
No alarm is represented by 0

Complete the following table which will determine when to sound the alarm.

Temperature Smoke Sound Alarm

1 0 1

1 1 1

0 0 0

0 1 1
(4 marks)

You might also like