#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();
}
#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();
}
0 comments:
Post a Comment