Ad Code

Ticker

6/recent/ticker-posts

Program To Check a Number Is Fibonacci Or Not

C Program:

/*program to check the number is fibonacci or not*/
#include<stdio.h>
#include<conio.h>
void main()
{
int f=1,f1=1,f2=0,n;
clrscr();
printf("Enter the number to be checked\n");
scanf("%d ",&n);
while(f<n)
{
f=f1+f2;
f1=f2;
f2=f;
}
if(f==n)
printf("%d is fibonacci\n",n);
else
printf("%d is not fibonacci\n",n);
getch();

}


OUTPUT:

Reactions

Post a Comment

0 Comments

Ad Code