//Code:
#include
#include
void main()
{
int n,fib0=0,fib1=1,fib;
clrscr();
printf("\n Enter the range of fibonacci series : ");
scanf("%d",&n);
printf("\n %d %d",fib0,fib1);
fib=fib0+fib1;
do
{
printf(" %d",fib);
fib0=fib1;
fib1=fib;
fib=fib0+fib1;
}while(fib<=n);
getch();
}
/*Output:
Enter the range of fibonacci series : 50
0 1 1 2 3 5 8 13 21 34
No comments:
Post a Comment