[问答题]

下列给定的程序中,函数fun()的功能是:求出以下分数序列的前n项和。2/1,3/2,5/3,8/5,13/8,21/13,……和值通过函数值返回main()函数。例如,若输入n=5,则应输出8.391667。
  注意:部分源程序给出如下。
  请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
/**********code.c**********/
#include <stdio.h>
#include <conio.h>
double fun(int n)
{
   int a=2,b=1,c,k;
   /**********found**********/
   double __1__;
   for(k=1;k<=n;k++)
   {
       s=s+0*a/b;
       /**********found**********/
       c=a,a+=__2__;b=c;
   }
   return(s);
}
main()
{
   int n=5;
   /**********found**********/
   printf(" The value of function is: ",__3__);
}
/**********-code.c**********/

参考答案与解析:

相关试题

下列给定的程序中,函数fun()的功能是:求出以下分数序列的前n项和。2/1,3/2,5/3,8/5,13/8,21/13,……和值通过函数值返回main()函数。例如,若输入n=5,则应输出8.39