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
2 Comments

2 comments:

shyama said...

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

Babali Kumari said...

Good
Here is a link for C/C++ programs and pointer programs. This may be useful for you.

C Programs

C++ Programs

Post a Comment