| Wyo Visual Basic Ch. 5 Worksheet #5 |
Name - |
Trace the following Do While loops. Neatly use columns on the right side of this worksheet to show the intermediate values each variable. Place single slashes through intermediate values except for the last value. Also indicate how many beeps would sound with each exercise. Assume that all variables have been declared and are initialized to zero. Indicate if any loop is infinite or if it never iterates even one time.
1.
intLoop1 = 56
Do While (intLoop1 > 0)
intLoop1 = intLoop1 - 12
Beep
Loop
2.
intCounter2 = 200
Do While (intCounter2 >= 1)
intCounter2 = -1 * intCounter2
Beep
Loop
3.
intCounter3 = 10
intNum3 = 15
Do While (intCounter3 < 60)
intCounter3 =intCounter3 + intNum3
intNum3 = intNum3 - 2
Beep
Loop
4.
intLoop4 = 50
intNum4 = 2
Do While (intLoop4 < 50)
intLoop4 =intLoop4 + 5
intNum4 = intNum4 - 4
Beep
Loop
5.
intLoop5 = 10
intNum5 = 2
Do While (intLoop5 < 50)
intLoop5 =intLoop5 + 5
intNum5 = intNum5 - 5
Beep
If (intNum5 < -10) Then
Exit Do
End If
Loop