问题 单项选择题

单击命令按钮时,下列程序代码的执行结果为 ( ) 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 Function Private Sub Commandl Click()Dim a As Integer, b As Integer, c As Integera=2 :b=3 :c=4Print SecProc(c, b, A) End Sub

A.21

B.19

C.17

D.34

答案

参考答案:A

解析: 执行语句Print SecProc (c,b,a)时,调用SecProc函数,此时将实参c, b,a的值对应传递给形参x,y,z。得SecProc =FirProc(a,c,b)+c,此时又需要调用Fir- Proc函数将a,c,b的值传递给对应形参x,y, z。在FirProc函数中执行语句FirProc=2*x +y+3*z即执行语句FirProe=2*a+c+3 *b其结果值为2*2+4+3*3即17。故 FirProe(a,c,b)的返回值为17。再与c相加即得SecProc函数的返回值结果21。选项A正确。

多项选择题 案例分析题
单项选择题