设有以下函数过程:Function fun(m As Integer) As IntegerDim k As Integer, sum As Integersum = 0For k = m To 1 Step -2sum = sum + kNext kfun = sumEnd Function若在程序中用语句 s = fun(10) 调用此函数,则s的值为______。

设有以下函数过程:

Function fun(m As Integer) As Integer

Dim k As Integer, sum As Integer

sum = 0

For k = m To 1 Step -2

sum = sum + k

Next k

fun = sum

End Function

若在程序中用语句 s = fun(10) 调用此函数,则s的值为______。


相关考题:

( 29 )有如下函数:Function fun(a As Integer,n As Integer) As IntegerDim m As IntegerWhile a =na=a-nm= m+1Wendfun=mEnd Function该函数的返回值是A ) a 乘以 n 的乘积B ) a 加 n 的和C ) a 减 n 的差D ) a 除以 n 的商(不含小数部分)

( 34 )某人设计了下面的函数 fun ,功能是返回参数 a 中数值的位数Function fun(a As Integer) As IntegerDim n%n = 1While a \ 10 = 0n = n + 1a = a \ 10Wendfun = nEnd Function在调用该函数时发现返回的结果不正确 , 函数需要修改 , 下面的修改方案中正确的是A ) 把语句 n = 1 改为 n = 0B ) 把循环条件 a \ 10 = 0 改为 a \ 10 0C ) 把语句 a = a \ 10 改为 a = a Mod 10D ) 把语句 fun = n 改为 fun = a

在窗体上画一个名称为Commandl的命令按钮,然后编写如下通用过程和命令按钮的事件过程: Private Function fun(By Val m As Integer) If m Mod 2=0 Then fun=2 Else fun=1 End If End Function Private Sub Commandl_Click() Dim i As Integer,s As Integer s=0 For i=1 To 5 s=s+fun(i) Next Print s End Sub 程序运行后,单击命令按钮,在窗体上显示的是______。A. 6B.7C.8D.9

D)DEFABC(32)某人为计算 n!(0n=12)编写了下面的函数过程:Private Function fun(n As Integer) As LongDim p As Longp=1For k=n-1 To 2 Step-1p=p*kNext kfun=pEnd Function在调试时发现该函数过程产生的结果是错误的,程序需要修改。下面的修改方案中有3 种是正确的,错误的方案是( )。A)把 p=1 改为 p=nB)把 For k=n-1 To 2 Step-1 改为 For k=1 To n-1C)把 For k=n-1 To 2 Step-1 改为 For k=1 To nD)把 For k=n-1 To 2 Step-1 改为 For k=2 To n

在窗体上有一个命令按钮Commandl,通用过程fun和命令按钮的事件过程如下: Private Function fun(By m As Integer) If m Mod 2=0 Then fun=2 Else Fun=1 Else If End Funcion Private Sub Commandl_Click() Dim i Integer,s As Integer s=0 For i=1 To 5 s=s+fun(i) Next Print s End Sub 程序运行后,单击命令按钮,则窗体上输出A.6 B.7 C.8 D.9

有如下的程序:Private Sub Command1_Click()Dim k As Integer,m AB IntegerDim P As Integerk=4:m=1P=Fun(k,m) =Print P;P=Fun(k,m) :Print PEnd SubPrivate Function Fun(a As Integer,b As Integer)Static m As Integer,i As Integerm=5:i=2i=i+m+1m=i+a+bFun=m\2End Function单击命令按钮后,输出结果为A. 2 2B.4 4C.5 5D.6 6

有如下函数过程: Function fun1(ByVal x As Integer,ByVal y As Integer) As Integer Do While y<>0 reminder=x Mod y x=y y=reminder Loop fun1=x End Function 在下列按钮单击事件中调用该函数,则该程序的运行结果是( )。 Private Sub Command1_Click() Dim a AS Integer Dim b As Integer a=100 b=25 x=fun1(a,B) Print x End SubA.0B.25C.50D.100

设有以下函数过程 Private Function Fun(a( )As Integer,b As String)As Integer … End Function 若已有变量声明: Dim x(5)As Integer,n As Integer,ch As String 则下面正确的过程调用语句是( )。A.x(O)=Fun(x."ch")B.n=Fun(n.ch)C.CallFun X,"ch"D.n=Fun(x(5),ch)

在窗体上画一个名称为Command1命令按钮,然后编写如下事件过程: Private Function fun1(n As Integer)As Integer Dim k As Integer If n = 1 Then k = 1 Else k = 1 + fun1(n - 1)* 2 End If fun1 = k End Function Private Sub Command1_Click () Dim m As Integer, x As Integer x = 4 m = fun1 (x) Print m End Sub 程序运行后,单击命令按钮,则窗体上显示的内容是A.4B.6C.9D.15

有如下函数过程: Function lj(x As Integer) As Long Dim s As Long Dim i As Integer s=0 For i = 1 To x s=s+ i Next i 1j= s End Function在窗体上添加一个命令按钮,名为Command1, 编写事件过程调用该函数: Private Sub Command1 Click() Dim i As Integer Dim sum As Long For i = 1 To 5 sum = sum + 1j(i) Next i Print sum End SubA. 25B.35C.45D.55

设有以下函数过程Private Function Fun(a()As Integer,b As String)As IntegerEhd Function若已有变量声明:Dim x(5)As Integer,n As Integer,ch As String则下面正确的过程凋用语句是A.x(0)=Fun(x,“ch”)B.n=Fun(n,ch)C.Call Fun x,“ch”D.n=Fun(x(5),ch)

设有以下函数过程:Functiofun(m As Integer)As IntegerDimk As Integer,sum As Integersum=0Fork=m To 1 Step-2sum=sum+kNextkfun=sumEnd Function若在程序中用语句s=fun(10)调用此函数,则s的值为______。

有下列函数过程:Function fun1(ByVal x As Integer,ByVal y As Integer)As IntegerDo While y<>0reminder=x Mod yx=yy=reminderLoopfun1=xEnd Function 在下列按钮单击事件中调用该函数,则该程序的运行结果是( )。Private Sub Command1_Click()Dim a As IntegerDim b As Integera=100b=25x=fun1(a,B)Print xEnd SubA.0B.25C.50D.100

有如下的程序: Private Sub Command1_Click() Dim k As Integer,m As Integer Dim P As Integer k=4:m=1 P=Fun(k,m):Print P; P=Fun(k,m):Print P End Sub Private Function Fun(a As Integer,b As Integer) Static m As Integer,i As Integer in=5:i=2 i=i+m+1 m=i+a+b Fun=m\2 End Function 单击命令按钮后,输出结果为A.2 2B.4 4C.5 5D.6 6

有如下函数过程: Function Fun(By Val x As Integer,By Val y As Integer)As Integer Do While Y<>0 reminder=x Mod y x=y y=reminder Loop Fun=x End Function 以下调用函数的事件过程,该程序的运行结果是 Private Sub Command7_Click() Dim a As Integer,b As Integer a=100:b=25 x=Fun(a,B) Print x End SubA.0B.25C.50D.100

在窗体上画一个名称为Command1的命令按钮,然后编写如下通用过程和命令按钮的事件过程; Private Function fun(ByVal m As Integer) If m Mod 2=0 Then fun=2 Else fun=1 End If End Function Private Sub Command1_C1ick() Dim i As Integer, s As Integer s=0 For i=1 To 5 s=s+fun(i) Next Print s End Sub 程序运行后,单击命令按钮,在窗体上显示的是______。A.6B.7C.8D.9

有如下的程序。Private Sub Command1_Click()Dim k As Integer, m As IntegerDim P As Integerk=4: m=1P=Fun(k, m) : Print P;P=Fun(k, m) : Print PEnd SubPrivate Function Fun(a As Integer, b As Integer)Static m As Integer, i As Integerm=5: i=2i=i + m + 1m=i + a + bFun=m \ 2End Function单击命令按钮后,输出结果为A.2 2B.4 4C.5 5D.6 6

有如下函数: Function fun(a As Integer,n As Integer)As Integer Dim m AS Integer While a=n a=a-n:m=m+1 Wend Fun=m End Function 该函数的返回值是。 A.a乘以n的乘积 B.a加n的和 C.a减n的差 D.a除以n的商(不含小数部分)

有如下的程序。 Private Sub Commandl_Click( ) Dim k As Integer, m As Integer Dim P As Integer k=4: m=1 P=Fun(k, m) : Print P; P = Fun ( k, m) : Print P End Sub Private Function Fun( a As Integer, b As Integer) Static m As Integer, i As Integer m=5:i=2 i=i+m+1 m=i + a + b Fun=m\2 End Function 单击命令按钮后,输出结果为A.2 2B.4 4C.5 5D.6

有下列函数过程: Function fun1(ByVal x As Integer,ByVal y As Integer)As Integer Do While y<>0 reminder=x MOd y x=y y=reminder Loop fun1=x End Function 在下列按钮单击事件中调用该函数,则该程序的运行结果是( )。 Private Sub Command1_Click() Dim aA.0B.25C.50D.100

有如下函数过程。 Function Fun( By Val x As Integer,By Val y As Integer) As Integer Do While y <> 0 reminder = x Mod y xmy y = reminder Loop Fun = x End Function 以下调用函数的事件过程,该程序的运行结果是 Private Sub CommandT_Click( ) Dim a As Integer,b As Integer a = 100:b =25 x =Fun(a,B)Print x End SubA.0B.25C.50D.100

有如下函数过程:Function Fun(By Val x As Ingeger, ByVal y As Integer)As IntegerDo While … y 0reminder=x Mod yx=yy=reminderLoopFun=xEnd Function以下是调用该函数的事件过程,该程序的运行结果是Private Sub Command1Dim a As IntegerDim b As Integera=100:b=25x=Fun(a,b)Print xEnd SubA.0B.25C.50D.100

在窗体上有一个命令按钮Command1,通用过程fun和命令按钮的事件过程如下: Private Function fun(ByVal m As Integer) If m Mod 2 = 0 Then fun=2 Else fun=1 End If End Function Private Sub Command1_Cliek() Dim i As Integer, s As Integer s=0 For i=1 To 5 s=s+fun(i) Next Print s End Sub 程序运行后,单击命令按钮,则窗体上输出( )。A.6B.7C.8D.9

有如下函数过程: Function Fun (By Val x As Ingeger, ByVal y As Integer)As Integer Do While…y<>0 reminder=x Mod y x=y y=reminder Loop Fun=x End Function 以下是调用该函数的事件过程,该程序的运行结果是 Private Sub Command1_Click() Dim a As Integer Dim b As Integer a=100:b=25 x=Fun(a,b)Print x End SubA.0B.25C.50D.100

在窗体上画一个按钮,然后编写如下的事件代码。在按钮上单击,输出为( )。 Private Function fun(x As Integer,y As Integer) Static m As Integer Static i As Integer i=i+2 i=i+m+1 m=i+x+y fun=m End Function Private Sub Command1_Click() Dim j As Integer,m As Integer,k As Integer j=4:m=1 k=fun(j,m) Print k; k=fun (j,m) Print k End SubA.8 18B.7 17C.7 19D.8 19

(23)设有以下函数过程Private Function Fun(a() As Integer, b As String) As Integer...End Function若已有变量声明:Dim x(5)As Integer, n As Integer, ch As String则下面正确的过程调用语句是A)x(o)=Fun(x, "ch")B)n=Fun(n, chC)Call Fun x, "ch"D)n=Fun(x(5), ch)

在应用程序中用Private Function fun(x As Integer,y AsInteger)定义了函数fun,调用函数fun的过程中的变量I,J均定义为Integer型,能正确引用函数fun的是()。 ①fun(I,J) ②Callfun(I,3.65) ③fun(3.14,234) ④fun(245,231.5)A、①③B、②③④C、①②③D、①②③④