long int fibonacci(int count);
long int fibonacci(int count)
{
static long int f1=1,f2=1,f;
f=(count<3?1:f1+f2);
f1=f2;
f2=f;
return f;
}
int main (void)
{
int count,n;
printf("How many fibonacci numbers?");
scanf("%d",&n);
for(count=1;count<=n;++count)
printf("i =%d F =%ld\n", count, fibonacci(count));
system("pause");
return 0;
}
1 comments:
The scope of a variable defined the sections of a program from where a variable can be accessed. The scope of variable in C depends upon it's place of declaration in C.
Post a Comment