Showing posts with label write cplusplus program to print fibonacci series. Show all posts
Showing posts with label write cplusplus program to print fibonacci series. Show all posts

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