Wednesday 21 December 2011


TO DISPLAY THE FIBONACCI NUMBERS WITHIN A RANGE BOTH UPPER AND LOWER BOUNDA ARE EXCLUDED




#include<stdio.h>
Void main()
{
Long lower,upper,a=1,b=0,c,temp;
Clrscr();
Printf(“enter a range\n”);
Printf(“wht is the lower bound ?”);
Scanf(“%d”,&lower);
Printf(“what is the upper bound ?”);
Scanf(“%d”,upper);
If(lower>upper)
{
Temp=lower;
Lower=upper;
Upper=temp;
}
Printf(“Fibonacci numbers between %d and %d are :\n”,lower,upper);
Do
{
C=a+b;
a=b;
b=c;
if((c>lower)&&(c<upper))
printf(“%d\t”,c);
}
While(c<upper);
Getch();
}

No comments:

Post a Comment