06/03/2023

Fibonacci Series in C++ Using Function | Fibonacci C++

Write a program to print the Fibonacci series in C++ Using Function. Check another program to find Fibonacci Series without using a Function I am sure you will get the concept. Fibonacci Series start with Zero and the next element is one then first we print 0 and 1. Now add two previous elements and print the next element as 0+1=1. repeat the process again and again until you get your answer.

Fibonacci Series program in C++ Using Function

Read: C++ Program For Fibonacci Series With Examples

0+1=1
1+1=2
1+2=3
2+3=5
3+5=8
5+8=13
8+13=21
13+21=34. . . .

Fibonacci Series in C++ Using Function


#include <iostream>
using namespace std;
int fibo(int n);
int main()
{
	int n, i = 0;
	cout << "\nEnter the nth term of fibonacci series in C++ using function";
	cin >> n;
	cout << "\nfibonacci Series in C++ is Given Below\n\n";

	while (i < n)
	{
		cout << " " << fibo(i);
		i++;
	}

	cout << " \n\n";
	return 0;
}

int fibo(int n)
{
	if ((n == 1) || (n == 0))
	{
		return (n);
	}
	else
	{
		return (fibo(n - 1) + fibo(n - 2));
	}
}

The Output of Fibonacci Series in C++


The Output of Fibonacci Series in C++

Similar to Fibonacci Series


Previous Post
Next Post

post written by:

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.
Follow Me

0 Comments: