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

 
#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

Your email address will not be published. Required fields are marked *