单选题 VB
题号 #485028

在窗体上画一个名称为Command1的命令铵钮,然后编写如下通用过程和命令按钮的事件过程.
Private Function f(m As Integer)
If m Mod 2=0 Then
f=m
Else
f=1
End If
End Function
Private Sub Command l_Click()
DimiAsInteger
s=0
For i=1 T0 5
s=s+f(i)
Next
Print S
End Sub
程序运行后,单击命令按钮,在窗体上显示的是 (  )

进入在线模考

参考答案

C

答案解析

函数f(m)的作用是判断m是否为偶数,如果是则返回m,否则返回1。s的值为f(l)=1、f(2)=2、f(3)=1、f(4)=4、f(5)=1之和,结果为9。所以答案是C。

你可能感兴趣的试题

找试题 · 找答案 · 找资料 在线模考