157. C Program to generate fibonacci Number using static.
How does this program work?
- This Program is used to generate fibnocci series using static.
Here is the code
int main()
{
//Generate Fibonacci series using static
int count, num1 = 0, num2 = 1, temp, i;
// User input
printf("Enter the number of terms:\n");
scanf("%d",&count ); span>
printf("First %d terms of Fibonacci series:\n",count);
for ( i = 0 ; i < count ; i++ )
{
if ( i <= 1 )
temp = i;
else
{
temp = num1 + num2;
num1 = num2;
num2 = temp;
}
printf("%d\t",temp);
}
return 0;
}