Computer Programming Name -
ACSL - WDTPD Worksheet #4 Period -
For loops are examples of repetition structures in Basic. They allow a programmer to write more efficient algorithms. Evaluate the following programs and list the running values of the loop variables, counters, and accumulators in the columns provided. Put single slashes through past values and circle the final value in each column.
Dim A, B As Integer A B
For A = 1 To 10
B = B + 1
Next A
End
Dim M, N, P As Integer M N P
For M = 50 TO 40 Step -2
N = N + 3
P = P + M
Next M
End
Dim J, K As Integer J K
K = 100
For J = 1 To 10 Step 4
K = K / 2
Next J
End
Dim R, S, T As Integer R S T
For R = 10 To 20
If R Mod 2 = 0 Then S = S + R
If R Mod 3 = 0 Then T = T + 1
Next R
End
Dim F, G, H As Integer F G H
For F = 1 To 200
G = G + F
H = SGN(F) + H
Next F
End