/*ratio of consecutive terms of fibonocci series*/
#include<stdio.h>
#include<math.h>
void
main()
{
int
i,f[100];
float
r0,r1;
i=0;
f[0]=1;
f[1]=1;
r1=1;
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:
enter the
number n=10
1.000000
1.0000002.000000
3.000000
5.000000
8.000000
13.000000
21.000000
34.000000
55.000000
s=1.617647
Press
any key to continue
No comments:
Post a Comment
Thanks for comment.