1. A 下列Visual Basic程式片段,若執行後power之值為8,則X之值應設為多少?
Dim i, power, N, X As Integer
i = 1 : power = 1 : N = 3 : X = ________
Do While i <= N
power = power * X
i = i + 1
Loop (100工管管理)
(A)2 (B)4 (C)6 (D)8
2 C 以下是一個加上行號的Do迴圈指令Visual Basic程式片段,執行後Ans之值為何?
1 Dim i, Ans As Integer
2 Ans = 1
3 i = 1
4 Do While i <= 10
5 If i Mod 2 = 0 Then
6 Ans = Ans * i
7 End If
8 i = i + 3
9 Loop (100商業類)
(A)9 (B)14 (C)40 (D)280