startMiner - free and simple next generation Bitcoin mining software

Program to check Fibonacci number

A program that get a number from the user and check if it is a fibonacci number or not:

Program check if number is a part of

fibonacci sequence or fibonacci series

using namespace std;
Program to Check Fibonacci Number
#include<iostream>
#include<conio.h>
int main()
{
int a,b,next,n;
cout<<"Enter a number:";
cin>>n;
if((n==0)||(n==1))
  cout<<"Entered number is fibonacci number";
else
{
a=0;
b=1;
next=a+b;

while(next<n)
{
Result of the Above Program
Output/Result
a=b;
b=next;
next=a+b;
    }
if(next==n)
 cout<<n<<" is fibonacci number";
else
 cout<<n<<" is not a fibonacci number";
    }
getch();
return 0;
}
Program to check Fibonacci number Program to check Fibonacci number Reviewed by Alpha on 3/18/2017 03:15:00 pm Rating: 5

No comments:

Theme images by mariusFM77. Powered by Blogger.