View Code of Problem 48

#include <stdio.h>
#include <string.h>

int main()
{
    int n ,k;
    double  sum=0;
    scanf("%d",&n);


    for(k=0;k<n;k++)
    {
    double  a,b,c,d,e,f,g,h,i,j;
    a=2.0/1;
    b=3.0/2;
    c=5.0/3;
    d=8.0/5;
    e=13.0/8;
    f=21.0/13;
    g=34.0/21;
    h=55.0/34;
    i=89.0/55;
    j=144.0/89;

    double  num[10]={a,b,c,d,e,f,g,h,i,j};
       sum=sum+num[k];
    
    }

    printf("%.6lf\n",sum );
  	return 0;
  }

Double click to view unformatted code.


Back to problem 48