问题 填空题

下列给定程序中,函数fun()的功能是;求S的值。设 S=(22/1*30))*(42/(3*5))*(62/(5*7))*…*(2k)2/((2k-1)*(2k+1))
例如,当k为10时,函数的值应为1.533852。
请改正程序中的错误,使它能得出正确的结果。
注童;不要改动main 函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio. h>
#include <stdio. h>
#include <math.h >
/**************found***************/
fun (int k)
iht n; float s, w, p, q;
n=1;
s=1.0;
while (n<=k)
w=2. 0*n;
p=w-1.0;
q=w+1.0;
s=s*w*w/p/q;
n++;

/***************found**************/
return s

main()
clrscr ();
printf ("%f\n ", fun (10));

答案

参考答案:(1)错误:fun(int k) 正确:double fun(int k)
(2)错误:return s 正确:returns;

解析:这样一道数学题要是用C程序来实现,真的挺简单,但我们还是需要注意细节问题上出的错误,该题便是如此。一个是简单的函数调用的定义,另一个是语法错误。

填空题
选择题