Saturday 31 January 2015

Fibonacci Series in C++ Program

Structure of the Problem Requirements 

 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 it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment