C program to find fibonacci series using recursion

C program to find fibonacci series using recursion


Input:

Enter n to find fibonacci series:

5

Output:


0 1 1 2 3


Implementation:


#include <stdio.h>

void printfibo(int n,int a,int b)
{
 int c;
 if(n==0)
  return;
 c=a+b;
 printf("%d ",c);
 printfibo(n-1,b,c);
}

int main(void) {
 int n;
 int a=-1,b=1;
 printf("Enter n to find fibonacci series:\n");
 scanf("%d",&n);
 printfibo(n,a,b);
 return 0;
}