执行循环后,两变量 I, Sum 分别是:
Dim I As Short = 1
Dim Sum As Long = 0
Do While I <= 5
Sum += I
I = I + 2
Loop
Dim I As Short = 1
Dim Sum As Long = 0
Do While I <= 5
Sum += I
I = I + 2
Loop
举一反三
- 下面程序运行后的结果为___ Private Sub Form_Click() Dim i%, sum% i = 1 Do While i < 5 sum = sum + i * i i = i + 2 Loop Print sum End Sub A: 45 B: 35 C: 10 D: 25
- 在下列程序段中,不能计算1到100之间奇数之和的是__________。 A: Dim sum As Integer sum = 0 For i = 1 To 100 Step 2 sum = sum + i Next B: Dim sum As Integer sum = 0 For i = 1 To 100 If i Mod 2 <> 0 Then sum = sum + i Next C: Dim sum As Integer sum = 0 For i = 1 To 99 sum = sum + i Next D: Dim sum As Integer sum = 0 For i = 100 To 1 Step -1 If i Mod 2 <> 0 Then sum = sum + i Next
- 下列VBA程序段的执行结果为 。 I = 1 Do While I<=10 SUM = SUM + I I = I + 1 Loop Debug.Print SUM
- 下列哪种循环语句可以求6,8,10,12,…,66数列的和,结果存放在sum变量中 A: i=6 sum=0 while i<67: if i%2==0: sum=sum+i i=i+1 B: i=6 sum=1 while i<67: if i%2==0: sum=sum+i i=i+1 C: i=6 sum=0 while i<=66: sum=sum+i i=i+2 D: i=6 sum=0 while i<=66: sum=sum+i i=i+2
- $sum = 0; for($i=1;$i<=100;;++$i){ if($i%2==0){ continue; } $sum += $i; } echo '$sum ='.$sum; echo输出值为_______。 2、 $sum = 0; for($i=1;$i<=100;;++$i){ if($i%2==0){ continue; } $sum += $i; } echo '$sum ='.$sum; echo输出值为_______