- C++ program to find factorial using recursive function
- C++ program to convert binary number to decimal and decimal to binary
- C++ program to display prime numbers between two intervals
- C++ program to print Pascal’s and Floyd’s triangle
- C++ program to print star pyramid patterns
- C++ Hello World Program
- C++ program to display Fibonacci series using loop and recursion
- C++ program to find area of the circle
- C++ program to calculate the area of the square with and without using function
- C++ program to encrypt and decrypt the string
- C++ program to convert temperature
- C++ program to check prime number
- C++ program to check palindrome number
- C++ program to make simple calculator using switch case
- C++ program for time conversion (convert time format)
- C++ program to find GCD or HCF
- C++ program to check for the power of two
- C++ program to check Armstrong number
- C++ program to check leap year
- C++ program to find LCM of two numbers

In this example, you will learn about C++ program to display Fibonacci series of first n numbers (entered by the user) using the loop and recursion.

**Fibonacci Series:** It is a series of numbers where the next term in series is the sum of previous two numbers.

Fibonacci Series: 0 1 1 2 3 5 8 13 ...

Here is the program to display Fibonacci series in C++.

```
//C++ program to implement Fibonacci series
#include<iostream>
using namespace std;
int main()
{
int oldNum, newNum, fibNum, maxNum;
//Enter maximum number till you want to generate Fibonacci series
cout << "Enter number: ";
cin >> maxNum;
oldNum = 0;
newNum = 1;
fibNum = oldNum + newNum;
cout << "\nFibonacci Series: " << oldNum << " " << newNum;
//while is true till fibNum is less than maxNum and fibNum is calculated
while(fibNum <= maxNum)
{
cout << " " << fibNum;
oldNum = newNum;
newNum = fibNum;
fibNum = oldNum + newNum;
}
cout << "\n";
return 0;
}
```

Output

```
//C++ program to display Fibonacci series using recursion
#include<iostream>
using namespace std;
int fibonacci(int n); //function declaration
int main()
{
int num, fibNum, i;
//Enter the total number in series
cout << "Enter the number of terms: ";
cin >> num;
fibNum = 0;
cout << "\nFibonacci Series: ";
for(i = 1; i <= num; i++)
{
cout << " " <<fibonacci(fibNum); //calling recursive function
fibNum++;
}
cout << "\n";
return 0;
}
//recursive function for Fibonacci series
int fibonacci(int n)
{
if(n == 0)
return 0;
else if (n == 1)
return 1;
else
return(fibonacci(n-1) + fibonacci(n-2)); //calling itself
}
```

Output

**Explanation**

In this program, we have used recursive function `fibonacci()`

to display Fibonacci series.

This program will display `num`

number of terms in Fibonacci series.