C Program to Display Fibonacci Series
Get Certified in C Programming and Take Your Skills to the Next Level
Program 1
// Program for Fibbonacci series
// 0 1 1 2 3 5 8 13 21 .......n
#include<stdio.h>
#include<conio.h>
int main()
{
int n,a,b,c,i;
a=0;
b=1;
system("cls");
printf("Enter the limit");
scanf("%d",&n);
if(n==1) // if limit is 1
printf("%d",a);
else
if(n==2) // if limit is 2
printf("%d %d ",a,b);
else
if(n>2) // if limit is 3
{
printf("%d %d ",a,b);
i=1;
while(i<=n-2)
{
c=a+b;
printf(" %d ",c);
a=b;
b=c;
i++;
}
}
}
If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

