#include<stdio.h>
#include<conio.h>
void main()
{
int num,s=0,x=-1,y=1,flag=0;
clrscr();
printf("Enter The Number:");
scanf("%d",&num);
while (s<num)
{
s=x+y;
if (s==num)
{
printf("%d belongs to fibonacci series",num);
flag=1;
break;
}
x=y;
y=s;
}
if (flag==0)
printf("%d is not in fibonacci series",num);
getch();
}
No comments:
Post a Comment