Task 1 Task 2 Task 3

Task 1

count ← 0

FOR i ← 0 TO 5

OUTPUT "Enter a number"

INPUT num

IF num > 0 THEN

count = count + 1

ENDIF

END FOR

Complete a following trace table for the above algorithm. The test data is:

-11 0 5 3 -1 6
count i num
     

Task 2

i ← 0

REPEAT

PRINT "Enter a number between 1 and 10:"

INPUT playerNum

IF playerNum > 5 THEN

i = i + 1

ENDIF

IF playerNum < 5 THEN

i = i - 1

ENDIF

UNTIL playerNum = -1

PRINT "i is ", i

Complete a trace table for the above algorithm. The test data is:

8 7 5 0 3 8 -1
i playerNum PRINT
     

Task 3

count ← 0

total ← 0

FOR i ← 0 TO 5

PRINT "Enter a temperature as a real number:"

INPUT temp

total ← total + temp

IF temp > 28.0 THEN

count = count + 1

ENDIF

END FOR

average ← total/6

Take a paper and pencil and complete the following trace table for the above algorithm. The test data is:

25.2 29.0 27.4 28.8 31.1 30.0
count total i temp average