Fibonacci series Program in C | C program to generate Fibonacci Series up to given Number
Description :
A series of whole numbers in which each number is the sum of the two preceding numbers. Beginning with 0 and 1, the sequence of Fibonacci numbers would be 0,1,1, 2, 3, 5, 8, 13, 21, 34, etc.
Program :
-
#include<stdio.h>
-
int main()
-
{
-
int i,j,k,num;
-
printf(“Enter any positive Number : “);
-
scanf(“%d”,&num);
-
/* because No Fibonacci series for Negative
-
* Numbers,. please enter more than 0. ex: 1,50,100.
-
*/
-
if(num > 0)
-
{
-
printf(“Fibonacci series is :”);
-
i=0;
-
j=1;
-
printf(” %d %d “,i,j);
-
k=i+j;
-
while(k <= num)
-
{
-
printf(“%d “,k);
-
i=j;
-
j=k;
-
k=i+j;
-
}
-
}
-
else
-
{
-
printf(“No fibonacci series for Negative Numbersn“);
-
}
-
printf(“n“);
-
}
Output :
![]() |
Output of Fibonacci Series Generator Program |