Sunday 18 August 2019

ratio of consecutive terms of fibonocci series - c program


/*ratio of consecutive terms of fibonocci series*/
#include<stdio.h>
#include<math.h>
void
main()
{
                int i;
                float r0,r1,f[100];
                i=0;
                f[0]=1;
                f[1]=1;
                r1=1.00;
label:
                r0=r1;
                i++;
                f[i+1]=f[i]+f[(i-1)];
                r1=f[i+1]/f[i];
                if(fabs(r1-r0)>0.001)
                                goto label;
                printf("the value of the ratio is %f\n",r1);
}
RESULT:
the value of the ratio is 1.618182
Press any key to continue


No comments:

Post a Comment

Thanks for comment.