#include<stdio.h>
#include<conio.h>
main()
{
int n,pn,nn,cn,num,flag;
clrscr();
printf("\n\n Enter a number to test : ");
scanf("%d",&num);
pn = 0;
nn = 1;
cn = pn + nn;
printf("\n\n FIBONACCI SERIES\n\n");
printf(" %d %d",pn,nn);
flag = 1;
while(cn <= num)
{
printf(" %d",cn);
if(num == cn)
flag = 0;
pn = nn;
nn = cn;
cn = pn + nn;
}
if( flag == 0)
printf("\n\n The given number %d is a fibonacci element\n\n",num);
else
printf("\n\n The given number %d is not a fibonacci element\n\n",num);
return 0;
}
No comments:
Post a Comment