Vous êtes sur la page 1sur 1

A student writes the following VBA program:

Option Explicit
Sub Quiz10()
Const m As Integer = 3
Dim i As Double, j As Double, x As Double, y(m + 1) As Double
i = 1: j = 2: x = 8
y(1) = 11: y(2) = 13: y(3) = 15: y(4) = 17
Do While (i <= 3)
If (i > 1) Then
y(i) = y(i) + j
ElseIf (i = 2) Then
y(i) = y(i) + x
Else
y(i) = y(i) - j
End If
y(i) = y(i) + MyFunc((i))
i = i + 1
Loop
MsgBox y(1) & " " & y(2) & " " & y(3) & " " & y(4)
y(1) = 31: y(2) = 33: y(3) = 35: y(4) = 37
For j = 1 To 4
Select Case j
Case Is > 3
Call MySub(y, j, 1)
Case 2.5 To 3.5
Call MySub(y, j, 2)
Case 2
Call MySub(y, j, 3)
Case Else
Call MySub(y, j, 4)
End Select
Next j
MsgBox y(1) & " " & y(2) & " " & y(3) & " " & y(4)
End Sub

Sub MySub(b, i, x)
b(i) = b(i) + x ^ 2
End Sub

Function MyFunc(g) As Double
MyFunc = g ^ 2 - g
End Function

After the student clicks on the run button, two message boxes are created. What values appear in the message boxes?

Vous aimerez peut-être aussi