C program to find Fibonacci series

C program to create Fibonacci series of given number.

Fibonacci series is the series of numbers where each number is the sum of two previous numbers. Like – Fibonacci series of 5 is – 0 1 1 2 3 5.

Program.

#include<stdio.h>
#include<conio.h>
void main()
{
int no,f=0,s=1,next,i;
printf("Enter any number series : ");
scanf("%d",&no);
printf("%d %d",f,s);
for(i=2;i<=no;i++)
{
next=f+s;
printf(" %d",next);
f=s;s=next;
}
getch();
return 0;
}

Output.

Enter any number series : 5
0 1 1 2 3 5