PROGRAM TO PRINT FIBONACCI SERIES

/*PROGRAM TO PRINT FIBONACCI SERIES*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,i,n;
clrscr();
printf(“Enter the limit of the series: “);
scanf(“%d”,&n);
if(n<1)
printf(“Enter only positive number”);
else
{
printf(“\nFibonacci series of %d numbers is: \n”,n);
a=0;
b=1;
printf(“%d %d “,a,b);
for(i=1;i<=n-2;i++)
{
c=a+b;
printf(“%d “,c);
a=b;
b=c;
}
getch();
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *