问题 填空题

下列程序用来计算1+2+…n,当和大于100时停止计算,请填空。
Private Sub Form_Click()
Dim n as integer,S as integer,I as integer,k as integer
s=0
k=0
n=inputbox(”请输入n的值)
For i=1 to 100
 k=k+1
 s=s+1
______
Next 1
Print s
End Sub

答案

参考答案:if s>100 then exit for

解析: 依题意,用变量s来记录1到n的累加和,当累加和s大于100时停止计算,故加入退出循环条件"if s>100 then exit for"。

选择题
单项选择题