题干

某两段VB程序分别如图1和图2所示:

Dim n As Integer, s As Integer, i As Integer

n=Val(Text1.Text)

s=0

For i=1 To n Step 2

 s=s+i

Next i

Text2.Text=Str(s)

图1

Dim n As Integer, s As Integer, i As Integer

n=Val(Text1.Text)

s=0

i=1

Do While i<=n

 s=s+i

 i=i+2

Loop

Text2.Text=Str(s)

图2

当n的值为10时,关于该两段程序,下列说法不正确的是(  )

A:两段程序中i的初值相同            

B:两段程序的运算结果不相同

C:两段程序都采用了循环结构           

D:图1程序实现了“1+3+5+7+9”和的运算

上一题 下一题 0.0难度 选择题 更新时间:2013-07-15 10:51:17

答案(点此获取答案解析)

B