下面程序的功能是____。Private Sub Command1_Click() Dim k%, i% k = 1 For i = 8 To 2 Step -2 k = k * i Next i Print kEnd Sub
A: 求2至8的所有整数的乘积
B: 求2至8的所有基数的乘积
C: 求2至8的所有偶数的乘积
D: 以上说法均不正确
A: 求2至8的所有整数的乘积
B: 求2至8的所有基数的乘积
C: 求2至8的所有偶数的乘积
D: 以上说法均不正确
举一反三
- 单击窗体,在窗体上打印数列:2/1 ,3/2 ,5/3 ,8/5 ,13/8 … 的前10项,并求其和,将和保存在变量s中。 Private Sub Form_Click() Dim i%, j%, k%, m As Integer Dim s As Single s = 0 i = 2 'i为分子 j = 1 'j为分母 For k = 1 To 10 s = 【1】 Print i & "/" & j m = j j = i i = 【2】 Next Print s End Sub
- 阅读程序: Sub subP(b()As Integer) For i=1 To 4 b(i)=2*i Next i End Sub Private Sub Command1_Click() Dim a(1 To 4)As Integer a (1)=5 a (2)=6 a (3)=7 a (4)=8 subP a() For i=1 To 4 Print a(i) Next i End Sub运行以上程序,单击命令按钮,输出结果为______ 。 A.2 4 6 8 B.5 6 7 8 C.10 12 14 16 D.出错
- 下列代码执行的结果是( )。 Private Sub Form_Click() Dim a(5) Dim i as Integer For i = 1 To 5 <br/>a(i) = i + 2 Next i Print a(4) End Sub A: 6 B: 8 C: 24 D: 2
- 有如下程序代码 Private Sub Command1_Click( ) Dim A(2 To 7) As Integer Dim i As Integer For i = 2 To 7 A(i) = i Next i print A(i - 2) End Sub 以上程序的执行结果是( )。
- 阅读程序: Option Base 1 Sub P(b() As Integer) For i=1 To 4 b(i)=2*i Next i End Sub Private Sub Form_Click() Dim a(4)As Integer For i=1 To 4 a(i)=i+4 Next i P a For i=1 To 4 Print a(i) Next i End Sub 运行上面的程序,单击窗体,输出结果为 A: 2 4 6 8 B: 5 6 7 8 C: 10 12 14 16 D: 4 8 12 16