count ← 0
FOR i ← 0 TO 5
OUTPUT "Enter a number"
num ← USERINPUT
IF num > 0 THEN
count = count + 1
ENDIF
NEXT i
Complete a following trace table for the above algorithm. The test data is:
| -11 | 0 | 5 | 3 | -1 | 6 |
|---|
| count | i | num |
|---|---|---|
i ← 0
REPEAT
PRINT "Enter a number between 1 and 10:"
playerNum ← USERINPUT
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 | |
|---|---|---|
count ← 0
total ← 0
FOR i ← 0 TO 5
PRINT "Enter a temperature as a real number:"
temp ← USERINPUT
total ← total + temp
IF temp > 28.0 THEN
count = count + 1
ENDIF
NEXT i
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 |
|---|---|---|---|---|