adsense

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

Write a program in C to print fibonacci series upto given number using recursive function.

Write a program in C to print fibonacci series upto given number  using recursive function.

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

Output:-


Post a Comment

0 Comments