Fibonacci Series in C++ Program

A series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. The simplest is the series 1, 1, 2, 3, 5, 8, etc.Here is the C++ code which will find the Fibonacci of a Number.

Source Code

#include<iostream>
using namespace std;
int main ()
{
 cout<<"\t \t \t LEP Tutorials \n\n\n";
 int num,sum;
 long previous =1,next =0;
 cout<<"Enter Number to Find  Fibonacci Series : ";
 cin>>num;
 while (next < num/2)
 {
  cout<<previous<<" ";
  sum = previous + next;
  next = previous ;
  previous = sum;
 }
}

Output of the Program

Fibonacci Series in C++ Program

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment