Tuesday, 10 January 2012

C program to print the Fibonacci series using recursion



#include<stdio.h>
void fib(int);
main()
{
int z;
printf("Enter the limit\n");
scanf("%d",&z);
printf("Fibonacci sequence\n");
fib(z);
}
void fib(int z)
{
static int a,b;
int c;
if(z<2)
{
a=0;
b=1;
}
else
{
fib(z-1);
c=b;
b=a+b;
a=c;
}
printf("\n%d",a);
}




You Like It!? Then kindly share with your Friends.
Comments
1 Comments

1 comment:

shyama said...

thanx...
if u need to checkout the previous year btech papers visit btech questionpaper

Post a Comment