C Program to Generate Fibonacci Series

In this program, you’ll learn C Program to Generate Fibonacci Series. Write a C Program to Generate Fibonacci Series.

#include<stdio.h>
#include<conio.h>
void main()
{
int n, f,s,new;
clrscr();
printf("Enter the final term of the series:");
scanf("%d",&n);
f=0;
s=1;
printf("%6d%6d",f,s);
new=f+s;
while(new<=n)
{
printf("%6d",new);
f=s;
s=new;
new=f+s;
}
getch();
}

Output :
Enter the final term of the series: 8
0 1 1 2 3 5 8