Wyo Visual Basic
Ch. 5 Worksheet #6
Name -

Deskcheck the following Do While loops, tracing the intermediate values of all loop variables. Neatly label 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. Assume that all variables are initialized to zero. Also indicate how many beeps would sound with each exercise. Indicate if any loop is infinite or if it never iterates even one time.

1.
intLoop1 = -10

Do While (intLoop1 > 0)
   intLoop1 = intLoop1 - 12 * (intLoop1 / 2)
   Beep
Loop

2.
intCounter2 = 200

Do While (intCounter2 <> 50)
     intCounter2 = intCounter2 - 50
     Beep
Loop

3.
intCounter3 = 10

Do While (intCounter3 < 20)
    intCounter3 =intCounter3 + intCounter3 Mod 3

    If (intCounter3 = 18) Then
        Exit Do
        Beep
    End If

    Beep
Loop

4.
intLoop4 = 1

Do While (intLoop4 < 500)
    intLoop4 =intLoop4 * 2
    Beep
Loop

5.
intLoop5 = 10
intNum5 = 50

Do While (intLoop5 < 50)
    intLoop5 =intLoop5 + 5
    intNum5 = intNum5 - 5
    Beep

    If (intNum5 < 20 ) And (intLoop5 > 35) Then
        intNum5 = 1000
        Exit Do
    End If

Loop

6.
intNum6 = 1
intLoop6 = 2

Do While (intLoop6 Mod 2 = 0)
    intNum6 = intNum6 * 2
    intLoop6 = intLoop6 + intNum6
    Beep

   If (intNum6 > 32) Then
       intNum6 = 1
   End If

Loop

7.
intA = 1
intB = 2
intFibonacci = 1

Do While (intFibonacci < 100)
    intFibonacci = intA + intB
    intA = intB
    intB = intFibonacci
    Beep
Loop

8.
intSwap1 = 5
intSwap2 = 4

Do While (intProduct < 21)
    intProduct = intSwap1 * intSwap2
    intTemp = intSwap1
    intSwap1 = intSwap2
    intSwap2 = intTemp
    Beep
Loop

9.
intNum9 = 2
intLoop9 = 7

Do While (intLoop9 * 3 > intNum9 * 3)
   intNum9 = intNum9 + 1
   Beep
Loop