CIS 230 - Visual Basic

Ch. 7 Worksheet #1

Determine how many times the following loops iterate and determine the final values of any variables upon the termination of each loop. If the loop is an infinite, simply write "infinite loop". If there is a syntax error, write "syntax error".

1.

For j = 1 To 11
    statements
Next j

j =

2.

For m = 10 To 23 Step 4
    statements
Next m

m =

3.

For intLoop = 1 To Len("Georgia")
    statements
Next intLoop

intLoop =

4.

k = 2
Do While k < 10
    k = k + 1
Loop

k =

5.

w = 45
Do
    w = w - 5
Loop Until w < 13

w =

6.

a = 5
b = Val(Right("123",1)
Do Until a < 0 And b <> 3
     a = a - 1
Loop

a =                              b =

7.

c = 13
d = -20
Do
    c = c + 2
    d = d + 1
Loop Until c = 99 Or d >= -19 And c > 17

c =                               d =

8.

For s = 14 To 28 Step 4/2
     statements
Next s

s =

9.

For h = 15 To 3 Step -5
     statements
Next h

h =