C语言:2. 求序列1/2,2/3,3/5,5/8,8/13,13/21……….前20项的和

#include <stdio.h>
main()
{
    int a,c=1;
    double sum=0,b=1.0,d,e,f;
    for(a=1;a<=20;a++)
    {
        d=b/(b+1);
        sum=sum+d;
        b=b+1;
        printf("%lf,%lf\n",b,d);
    }
    printf("%.3lf",sum);
    getchar();
 }

 

posted @ 2022-09-15 10:39  myrj  阅读(113)  评论(0编辑  收藏  举报