### Fibonacci Series or Sequence in C++

Today in**C++ Tutorial**we will learn

**How to write C++ program to find Fibonacci Series**.The Fibonacci Sequence can be written as 0,1,1,2,3,5,8,13........

### What is Fibonacci Series or Sequence

The Fibonacci numbers or Fibonacci series or Fibonacci sequence has first two numbers equal to 1 and 0 and the further each number is consist of the addition of previous two numbers.

1st number = 0

2nd number = 1

3rd number = 0+1= 1

4th number = 1+1= 2

5th number = 1+2= 3

And so on.

The Fibonacci Sequence can be written as 0,1,1,2,3,5,8,13........

if part will run. let input is equal to 5

Before loop variables values

1st number = 0

2nd number = 1

3rd number = 0+1= 1

4th number = 1+1= 2

5th number = 1+2= 3

And so on.

The Fibonacci Sequence can be written as 0,1,1,2,3,5,8,13........

### Fibonacci Series program logic

- Before writing C++ Program we must know that what is Fibonacci Series and in what sequence numbers occurs.
- After understanding mathematically Fibonacci series completely we write it in the form of C++ Program.
- As the Fibonacci series is infinite but we can't make a program that display an infinite output.
- In below program we take input the range in integer up-to which Fibonacci series will be displayed.
- For this purpose a
**for loop**has been taken which starts from 0 and terminates less than range for example if Input is 5 then for loop will run from 0 to 4. - In for loop if variable 'c' is less or equal than 1 in this case if statement will be executed and if 'c' is greater than 1 else part will be executed for greater than 1.

if part will run. let input is equal to 5

Before loop variables values

### How to write C++ program to find Fibonacci Series

Lets have a Look at C++ program to find Fibonacci Series upto given Limit.
This C++ program use simple logic to get the concept of writing code in C++ for Fibonacci Series.

using namespace std;

int main()

{

int range, first = 0, second = 1, result=0;

cout << "Enter Range for Terms of Fibonacci Sequence: ";

cin >> range;

cout << "Find Fibonicci Series upto : " << range << " Terms "<< endl;

for ( int c = 0 ; c < range ; c++ )

{

if ( c <= 1 )result = c;

else

{result = first + second;

first = second;

second = result;

}

cout <<result <<" ";

}

return 0;

}

How to write C++ program to find Fibonacci Series

How to Write C++ Program to Find Prime Number

How to write C++ Program to find factorial of Number

What is Recursive function in c++ with Examples

C++ program to Make Simple calculator

Find the HCF and LCM by using the C++

### C++ program to find Fibonacci Series

#include<iostream>using namespace std;

int main()

{

int range, first = 0, second = 1, result=0;

cout << "Enter Range for Terms of Fibonacci Sequence: ";

cin >> range;

cout << "Find Fibonicci Series upto : " << range << " Terms "<< endl;

for ( int c = 0 ; c < range ; c++ )

{

if ( c <= 1 )result = c;

else

{result = first + second;

first = second;

second = result;

}

cout <<result <<" ";

}

return 0;

}

### C++ PROGRAMMING EXAMPLE CODES

Write ALLAH Using C++ ProgramHow to write C++ program to find Fibonacci Series

How to Write C++ Program to Find Prime Number

How to write C++ Program to find factorial of Number

What is Recursive function in c++ with Examples

C++ program to Make Simple calculator

Find the HCF and LCM by using the C++

**Tags:**c, c++, c++ tutorials, Programming in C++, write a c++ program, Fibonacci Series, Fibonacci series in c++, Fibonacci series in cplusplus, Fibonacci series logic, program to find Fibonacci series, what is Fibonacci series,
## 0 comments:

## Post a Comment