Print Fibonacci series using recursive function - C

Write recursive program to print Fibonacci series for n terms.

Solution:

#include<stdio.h>
long int fib(long int i)
{
     long int res;
     if(i==0||i==1)
          return (i);
     else
          res=fib(i-1)+fib(i-2);
     return(res);
}
int main()
{
     long int res,n;
     int i;
     printf("/*How Many Terms You Want to \nCalculate in Fibonacci Series*/\n\nEnter Limit : ");
     scanf("%ld",&n);
     printf("\n");
     for(i=0;i<n;i++)
     {
          res=fib(i);
          printf("%ld ",res);
     }
     return 0;
}


Output:

fibonacci series