Learn C ProgrammingLearn ProgrammingPrograms On More On FunctionsResources

064. Write a program using recursions for fibbonacci series in C language

By September 18, 2012 September 5th, 2018 No Comments

#include<stdio.h>
#include<conio.h>  
#include<process.h>
fibbo(int pre, int cur ,int x)
{        int temp;
	if(x==2)
	{
		getch();
		exit(0);
	}
	temp=cur;
	cur=pre+cur;
	pre=temp;
	printf("%d ",cur);
	fibbo(pre,cur,x-1);
}
main()
{
	int n,pre=1,cur=1;
	clrscr();
	printf("Enter number : ");
	scanf("%d",&n);
	printf("%d %d ",pre,cur);
        fibbo(pre,cur,n);
	getch();
}

Leave a Reply

DEMO01