计算机二级

单击命令按钮,下列程序的执行结果是 Private Sub Blck (x As Integer) x = x * 2 + l If x <6 Then Call Blck(x) End If x = x * 2 + 1 Print x; End Sub Private Sub Commandl_Click() Blck 2 End SubA.23 47B.10 36C.22 44D.24 50

题目

单击命令按钮,下列程序的执行结果是 Private Sub Blck (x As Integer) x = x * 2 + l If x <6 Then Call Blck(x) End If x = x * 2 + 1 Print x; End Sub Private Sub Commandl_Click() Blck 2 End Sub

A.23 47

B.10 36

C.22 44

D.24 50

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

单击命令按钮时,下列程序的执行结果是

Private Sub Command1_Click()

BT 4

End Sub

Private Sub BT(x As Integer)

x=x * 2 + 1

If x < 6 Then

Call BT(x)

End If

x=x * 2

Print x;

End Sub( )。

A.15

B.16

C.17

D.18


正确答案:D

第2题:

(13)单击命令按钮时,下列程度的执行结果是 Private Sub Command1_Click() Dim a As Integer,b As Integer,c As Integer a=2:b=4:c=6 Call S2(a,b) Print"a=";a;"b=";b;"c=";c; End Sub Private Sub S1(x As Integer,y As Integer) Dim c As Integer x=2*x:y=y+2:e=x+y End Sub Sub S2(x As Integer,By Val y As Integer) Dim e As Integer x=2*x:y=y+2:e=x+y End Sub A.a=4 b=6 c=6 B.a=8 b=6 c=6 a=4 b=6 c=6 a=8 b=6 c=6 C.a=4 b=6 c=6 D.a=8 b=6 c=6 a=8 b=6 c=6 a=4 b=6 c=6


正确答案:C
【解析】在定义子过程的参数时,如果在参数前加上ByVal,表示是“传值”参数,主调函数中参数的值不被改变;否则表示是“传地址”参数,参数值会被调用的子过程改变。
题中S1过程的参数是“传地址”,因此调用后a、b、c的值都改变了,分别为4、6、6;S2过程的参数中a是“传地址”参数,b是“传值”参数,因此调用后a值改变,b值不变,因为。是过程变量,所以也没有变化,因此输出的值为8、6、6。

第3题:

单击命令按钮执行下列程序,其输出结果是。 Private Sub Commana1_Click() Dim a As Integer,b As Integer,c As Integer a = 3 b = 4 c = 5 Print SecProc(c,b,a) End Sub Function FirProc(x As Integer,y As Integer,z As Integer) FirProc = 2 * x + y + 3 * z End Function Function SecProc(x As Integer,y As Integer,z As Integer) SecProc = FirProc(z,x,y) + x End FunctionA. 20 B. 22 C. 28 D. 30


正确答案:C
【解析】本题是在Commana1过程中调用SecProc函数,而在SecProc函数中又调用了FirProc函数。函数调用时,实参和形参要一一对应传递。程序运行过程是:①Print SecProc(c,b,a)→Print SecProc(3,5,4);②SecProc = FirProc(z,x,y) + x→SecProc = FirProc(3,5,4) + 5;③FirProc = 2 * x + y + 3 * z→FirProc = 2 * 3 + 5 + 3 * 4=23;④SecProc = 28→Print SecProc(c,b,a)→Print28.形参是在被调用的Sub、Function过程中定义的参数名;实参则是在调用的Sub或Function过程中定义的参数名。

第4题:

单击命令按钮时,下列程序的执行结果为 Private Sub Command1_Click() Dim a As Integer,b As Integer,c As Integer a=2:b=3:C=4 Print P2(c,b,A)End Sub Private Function P1(x As Integer,y As Integer,z As Integer) P1=2 * X + y + 3 * z End Function Private Function P2(x As Integer,y As Integer,z As Integer) P2=P1(z,x,y) + X End Function

A.21

B.19

C.17

D.34


正确答案:A
解析:对于多个过程或函数依次调用和处理与简单过程调用处理一样,本题先调用函数P2,而函数P2又调用函数P1,结果返回的顺序是从P1到P2,P2计算后输出到调用的地方。

第5题:

单击命令按钮时,下列程序的执行结果是

Private Sub Command1_Click()

BT 4

End Sub

Private Sub BT(x As Integer)

x=x*2+1

If x<6 Then

Call BT(x)

End If

x=x*2

Print x;

End Sub

A.15

B.16

C.17

D.18


正确答案:D
解析:此题在函数调用过程中采用了简单递归的方式,具体流程如下:主调过程调用BT过程,把实参4传递给BT过程中的形参x,由x=x*2+1语句推出x=9,此时不满足BT过程中判断语句的判断条件,执行x=x*2;Print x;语句。由x=x*2语句得到x值为18并输出,结束此次调用过程,返回到主调过程结束程序,输出结果为18。

第6题:

单击命令按钮时,下列程序的执行结果为( )。 Private Sub Commandl_Click() Dimx As Integer,y As Integer x=12: y=32 CallPCS(x,y) PrintX;y End Sub PubUc Sub PCS(ByValn As Integer,ByValm As Integer) n=nMod 10 m=mMod 10 End Sub

A.1232

B.232

C.23

D.123


正确答案:A

第7题:

单击命令按钮时,下列程序的执行结果是

Private Sub Command1_Click()

Dima As Integer,b As Integer,c As Integer

a=3:b=4:c=5

Print SecProc(c,b,A)End Sub

Function FirProc(x As Integer,y As Integer,z As Integer)

FirProc=2*x+y+3*z+2

End Function

Function SecProc(x As Integer,y As Integer,z As Integer)

SecProc=FirProc(z,x,y) +x+7

End Function

A.20

B.25

C.37

D.32


正确答案:C
解析:此题程序代码中用了嵌套调用,我们对这样的问题要多加小心,千万不要把实参和相对应的形参弄混。主调过程Commandl_Click输出的是SecProc(c,b,A)的返回值,调用过程SecProc时,主调过程分别把实参c、b、a地址传给形参x、y、z,此时在过程SecProc中,SecProc=FirProc(a,c,B)+7。由此看出,程序段执行此语句时,将调用过程FirProc。把实参a,c,b的地址分别传给形参x、y、2,此时在过程FirProc中,FirProc=2*x+y+3*z+2,所以FirProc(a,c,B)=6+4+15 +2=27,SecProc(a,c,B)=27+3+7=37。

第8题:

单击命令按钮,下列程序的执行结果是

Private Sub Blck(x As Integer)

x=x * 2 + 1

If x < 6 Then

Call Blck(x)

End If

x=x * 2 + 1

Print x;

End Sub

Private Sub Command1_Click()

Blck 2

End Sub( )。

A.23 47

B.10 36

C.22 44

D.24 50


正确答案:A

第9题:

单击命令按钮时,下列程序代码的执行结果为______。 Private Sub Proe1 (n As Integer,ByVa1 m As Integer) n=n Mod 10 m=m\ 10 End Sub Private Sub Command1_Click() Dim x As Integer Dim y As Integer x= 12 y = 34 Call Proe1 (x, y) Print x; y End Sub

A. 12 34

B.2 34

C.2 3

D.12 3


正确答案:B

第10题:

在窗体中添加一个名称为Cmd的命令按钮,然后编写如下程序: Public x As integer Private Sub Cmd_Click() x=10 Call add1 Call add2 MsgBox x End Sub Private Sub add1 ( ) x=x+20 End Sub Private Sub add2 ( ) Dim x As integer x=x+40 End Snb 窗体打开运行后,单击命令按钮,则消息框的输出结果为( )。

A.10

B.60

C.30

D.70


正确答案:C
解析:公有变量x,在add1中对其值加20为30,但在add2中又定义了私有变量x,这时私有变量有效。所以x的值仍然为30。

更多相关问题