问题 单项选择题

现有如下程序:

Private Sub Command1_Click()

s=0

For i=1 To 5

s=s+f(5+i)

Next

Print s

End Sub

Public Function f(x As Integer)

If x>=10 Then

t=x+1

Else

t=x+2

End If

f=t

End Function

运行程序,则窗体上显示的是()。

A.38

B.49

C.61

D.70

答案

参考答案:B

解析:

本题考查的考点是有关函数调用和If语句的。要注意在前4次循环中每次调用f函数时传递的参数分别为6、7、8、9,都是小于10的;最后一次循环传递参数10。所以最终结果应该为 8+9+10+11+11=49

默写题
判断题