adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

C program for fibonacci series using recursive function

#include<stdio.h>
#include<conio.h>
 int fibo(int x);
 int main()
  {
  int n,i;
  printf("Enter a no->");
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  printf("%4d",fibo(i));
  return 0;
  }
  int fibo(int x)
     {
      if(x==1)
        return 0;
      else if(x==2)
        return 1;
      else
         return (fibo(x-1)+fibo(x-2));
      }

Output:

        

Post a Comment

0 Comments