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. . . .
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++
Similar to Fibonacci Series
- C++ Program to Display the Grade of a Student Using Switch Case
- C++ Program to Convert Celsius to Fahrenheit And Vice Versa
- C++ Program to Perform Arithmetic Operations Using Switch Case
- C++ Program to Find Area of a Triangle/Square/Circle/ Rectangle Using Switch Statement
- C++ Program to Print Table of Any Number Using For Loop
0 Comments: