C Program To Print Fibonacci Series Using Recursion

#include<stdio.h>
#include<conio.h>

void fib(int n)
{
static int first=0,second=1,sum;

if(n>0)
{

sum=first+second;
first=second;
second=sum;
printf("%d  ",second);
fib(n-1);
}

}

void main()
{
int n;
clrscr();
printf("Enter any number  : ");
scanf("%d",&n);
printf("\n\nPrinting  :   0  1  ");
fib(n);

getch();

}
Share on Google Plus

About Akash Manhas

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment