全部题库 / VB / 试题详情
单选题 VB
2013-08-15

计算的近似值的一个公式是π/4=1-(1/3)+(1/5)-(1/7)+…+(-1)n-1(1/2n -1)。
某人编写下面的程序用此公式计算并输出的近似值:
Private Sub Cornmand1 Click(  )
P1=1
Sign=1
n=20000
For k=3 To r
Sign=-Sign
PI=PI+SiRn/k
Next k
Print PI*4
End Sub
运行后发现结果勾3.22751,显然,程序需要修改。下面修改方案中正确的是(  )。

A.把For k=3 To n改为For k=1 To n
B.把n=20000改为n=20000000
C.把For k=3 To n改为For k=3 To n Step 2
D.把PI=1改为P1=0

参考答案

C

答案解析

c。【解析】Stop用在for循环中,表示每一次循环,变量增加几,本题中按照公式,k作为分母,值应为奇数,所以应用Fo,k=3 To n Step 2。是从3开始的奇数,所以本题为C。

你可能感兴趣的试题

A.Print arr.Code(2),art.Caption(2)
B.Print art.Code,arr.Caption
C.Print arr(2).Code,arr(2).Caption
D.Print Code(2),Caption(2)