xxxxxxxxxx
#include<stdio.h>
int main()
{
int min,max;
int n=min;
int a=0,b=1,c=0;
scanf("%d%d",&min,&max);
if((min<0)&&(max>0))
{
printf("min range is invalid");
}
else if((max<0)&&(min>0))
{
printf("max range is invalid");
}
else if((min<0)&&(max<0))
printf("both inputs invalid");
else
{
if(min<1)
printf("%d %d ",a,b);
c=a+b;
while(c<=max)
{
c=a+b;
if(c>=min)
{
if(c<max)
printf("%d ",c);
}
a=b;
b=c;
}
}
}
xxxxxxxxxx
#include<stdio.h>
int main()
{
int a=1, b=1, range, c, sum=0;
printf("Enter the range of Fibonacci series: ");
scanf("%d",&range);
printf("The fibonacci series is: \t");
while( a <= range )
{
printf("%d\t",a);
sum += a;
c = a + b;
a = b;
b = c;
}
printf("\nTheir sum is = %d", sum);
return 0;
}
xxxxxxxxxx
#include<stdio.h>
int main()
{
int min,max;
int n=min;
int a=0,b=1,c=0;
scanf("%d%d",&min,&max);
if((min<0)&&(max>0))
{
printf("min range is invalid");
}
else if((max<0)&&(min>0))
{
printf("max range is invalid");
}
else if((min<0)&&(max<0))
printf("both inputs invalid");
else
{
if(min<1)
printf("%d %d ",a,b);
c=a+b;
while(c<=max)
{
c=a+b;
if(c>=min)
{
if(c<max)
printf("%d ",c);
}
a=b;
b=c;
}
}}