Ques: Program to print fibonacci series of given range such that series last number will be less than or equal to given no.
#include<stdio.h>
int main( )
{
int n, a=1, b=1, temp;
printf("Enter the number");
scanf("%d",&n);
printf("Fibonacci series is %d %d ", a,b);
while(a+b<=n)
{
temp=a;
a=b;
b=a+temp;
printf("%d ",b);
}
return 0;
}
#include<stdio.h>
int main( )
{
int n, a=1, b=1, temp;
printf("Enter the number");
scanf("%d",&n);
printf("Fibonacci series is %d %d ", a,b);
while(a+b<=n)
{
temp=a;
a=b;
b=a+temp;
printf("%d ",b);
}
return 0;
}
0 Comments