Series 0, 1, 1, 2, 3, 5, 8, 13, 21 . . . . . . . is a Fibonacci series. In Fibonacci series, each term is the sum of the two preceding terms. The C and C++ program for Fibonacci series using recursion is given below. C Program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

#include<stdio.h> int fibonacci(int n) { if((n==1)(n==0)) { return(n); } else { return(fibonacci(n1)+fibonacci(n2)); } } int main() { int n,i=0; printf("Input the number of terms for Fibonacci Series:"); scanf("%d",&n); printf("\nFibonnaci Series is as follows\n"); while(i<n) { printf("%d ",fibonacci(i)); i++; } return 0; } 
C++ Program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

#include<iostream> using namespace std; int fibonacci(int n) { if((n==1)(n==0)) { return(n); } else { return(fibonacci(n1)+fibonacci(n2)); } } int main() { int n,i=0; cout<<"Input the number of terms for Fibonacci Series:"; cin>>n; cout<<"\nFibonacci Series is as follows\n"; while(i<n) { cout<<" "<<fibonacci(i); i++; } return 0; } 
Output: