# C++ Program For Fibonacci Series With Examples

Problem:- Write A C++ Program To Find Fibonacci Series Or C++ Program For Print Fibonacci Series Or C++ Program For Fibonacci Series With Examples.

Logic:- For Print Fibonacci Series We Use Simple Method. As we know that Fibonacci Series is started with Zero (0) and next Element is One Then we add previous two elements and print next element of Fibonacci Series.This process repeats up to n times, suppose you want to print a Fibonacci series up to 5 terms then you need to repeat this process up to 5 times and so on.

Explanation:- Fibonacci Series start with Zero and next element is one then first we print 0 and 1. Now add two previous elements and print then next element is 0+1=1. repeat the process again and again until you get your answer.
0+1=1
1+1=2
1+2=3
2+3=5
3+5=8
5+8=13
8+13=21
13+21=34. . . .

Done.

Fibonacci Series:- In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones.

Fibonacci Series :- 1 ,1 ,2 ,3 ,5 ,8 ,13 ,21 ,34.

Often, especially in modern usage, the sequence is extended by one more initial term.

Fibonacci Series :- 0 ,1 ,1 ,2 ,3 ,5 ,8 ,13 ,21 ,34.

The Fibonacci numbers occur in the sums of "shallow" diagonals in Pascal's triangle see in the given picture

source=wikipedia

Important Fact about Fibonacci Series:- 'The 'Golden Ratio' or Phi' of any two consequent numbers of the sequence in Fibonacci Series is 1.618 or 1.6 (approx) Except starting 4 terms.

Example:- The first 21 Fibonacci numbers Fn for n = 0, 1, 2, …, 20 are given below.

Fibonacci Series :- 0 ,1 ,1 ,2 ,3 ,5 ,8 ,13 ,21 ,34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765.

3 / 2             = 1.500
5 / 3             = 1.667
8 / 5             = 1.600
13 / 8           = 1.625
21 / 13         = 1.615
34 / 21         = 1.619
55 / 34         = 1.617
89 / 55         = 1.618
144 / 89       = 1.618
233 / 144     = 1.618
377 / 233     = 1.618
610 / 377     = 1.618
987 / 610     = 1.618
1597 / 987   = 1.618
2584 / 1597 = 1.618
4181 / 2584 = 1.618
6765 / 4181 = 1.618

Solution:-

#include<iostream>
using namespace std;
int main()
{
int a=0,b=1,i,n,c;

cout<<"Enter The Number \n\n"; //Enter the number of terms
cin>>n;

cout<<"\nFibonacci Series Is \n\n"; //Fibonacci Series Is given below
cout<<a<<" "<<b<<" ";

for(i=0;i<n;i++)
{
c=a+b;           //here adding two previous value
cout<<c<<" ";
a=b;              //swap the value
b=c;              //here first two value result stored in 'b'
}                     //Loop end.
cout<<"\n";
return 0;

}

Output:-

You May Also Like:-

Previous Post
Next Post

#### post written by: Ghanendra Yadav

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.

1. 1. 2. 