Write a C program to generate Fibonacci numbers from 1 to n.
manikanta veerla
10mo
int main()
{
int n;
scanf("%d",&n);
int a=0,b=1;
printf("%d %d ",a,b);
int count =0;
while(count less than n-2)
{
int sum=a+b;
a=b;
b=sum;
if(sum>n)
break;
count++;
printf("%d ",sum);
}
return 0;
}
Help your peers!
Add answer anonymously...
>
Efftronics Systems firmwa Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

