64. C Program To find Fibonacci Series of a Given Number.
How does this program work?
- This Program is used to find the Fibonacci series of a given number.
- here the for loop is used to get the series.
Here is the code
#include <stdio.h>
int main(void)
{
//initialize Variables
int n1=0,n2=1,n3,i,number;
printf("Enter the number of elements:");
scanf("%d",&number);
printf("\n%d %d",n1,n2);
//loop to print Fibonacci series
for(i=2;i < number;++i)
{
n3=n1+n2;
printf( " %d",n3);
n1=n2;
n2=n3;
}
return 0;
}