C Programs / Fibonacci series c program

Program Name Write a c Program for Fibonacci series.
Code
#include 
int main()
{
int j,a=0,b=1,sum,fs;
printf("Enter Series limit: ");
scanf("%d",&fs);
printf("Fibonacci series: \n");
printf("%d %d ",a,b);
for(j=3;j<=fs;j++)
{
sum=a+b;
printf("%d ",sum);
a=b;
b=sum;
}
return 0;
}
Input Enter Series limit: 6
Output Fibonacci series:
0 1 1 2 3 5


Home     Back