Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Fibonacci Series Program In C Language
WhatsApp
Ashish Srivastava
Apr 03
2016
749
0
0
#include<stdio.h>
#include<conio.h>
void
fseries(
int
);
void
main()
{
int
limit,f0=1,f1=1;
clrscr();
printf(
"Enter the limit of fibonacci series"
);
scanf(
"%d"
,&limit);
if
(limit>2)
{
printf(
"%d\n%d"
,f0,f1);
fseries(limit-2);
}
else
if
(limit==2)
{
printf(
"\n %d \n %d"
,f0,f1);
}
else
if
(limit==1)
printf(
"%d"
,f1);
else
printf(
"Series not posible"
);
getch();
}
void
fseries(
int
p)
{
int
fib;
static
int
f0=1,f1=1;
if
(p==0)
{
printf(
"\nThe series ends here"
);
}
else
{
fib=f0+f1;
f0=f1;
f1=fib;
printf(
"\n%d"
,fib);
fseries(p-1);
}
}
Fibonacci series
C
Up Next
Fibonacci Series Program In C Language