( 33 )设有如下程序:
Private Sub Commandl Click ()
Dim sum As Double, x As Double
sum = 0
n = 0
For i=l To 5
x = n / i
n = n + 1
sum 二 sum + x
Next i
End Sub
该程序通过 For 循环来计算一个表达式的值,这个表达式是
A ) 1+1/2+2/3+3/4+4/5
B ) 1+1/2+1/3+1/4+1/5
C ) 1/2+2/3+3/4+4/5
D ) 1/2+1/3+1/4+1/5
第1题:
在窗体上画一个名称为Commandl的命令按钮,然后编写如下事件过程: Private Sub Command1_Click() x = 0 n=InputBox(" ") For i = 1 To n For j=1 To i x = x + 1 Next i Next i Print x End Sub 程序运行后,单击命令按钮,如果输入3,则在窗体上显示的内容是
A.3
B.4
C.5
D.6
第2题:
设有如下程序: Private Sub Command1_Click() Dim Sum As Double, x As Double sum=0 n = 0 For i= 1 To 5 x = n / i n = n + 1 sum=sum+x Next End Sub 该程序通过For循环计算一个表达式的值,这个表达式是
A.1+1/2+2/3+3/4+4/5
B.1+1/2+2/3+3/4
C.1/2+2/3+3/4+4/5
D.1+1/2+1/3+1/4+1/5
第3题:
设有如下程序: Private Sub Command1_Click( ) Dim sum As Double,x As Double sum=0 n=0 For i=1 To 5 x=n/i n=n+1 sum=sum+x Next End Sub 该程序通过For循环计算一个表达式的值,这个表达式是
A.1+1/2+2/3+3/4+4/5
B.1+1/2+2/3+3/4
C.1/2+2/3+3/4+4/5
D.1+1/2+1/3+1/4+1/5
第4题:
设有如下程序: Private Sub Cimmandl_Click. Dim sum As Double, x As Double Sum=0 n =0 For i =1 To 5 x =n/i n =n +1 sum =sum +x Next i End Sub 该程序通过For 循环来计算一个表达式的值,这个表达式是 A.1+1/2+2/3+3/4+4/5 B.1+1/2+1/3+1/4+1/5 C.1/2+2/3+3/4+4/5 D.1/2+1/3+1/4+1/5
第5题:
设有如下程序: Private Sub Command1_Click() Dim sum As Double, x As Double sum=0 n=0 For i=1 To 5 x=n/i n=n+1 sum=sum+x Next End Sub 该程序通过For循环计算一个表达式的值,这个表达式是______。
A.1+1/2+2/3+3/4+4/5
B.1+1/2+2/3+3/4
C.1/2+2/3+3/4+4/5
D.1+1/2+1/3+1/4+1/5
第6题:
5、写出如下程序的运行结果和运行原理: sum = 0 n = 99 while n > 0: sum = sum + n n = n - 2 print(sum)