fibonacci series in c
program:-
#include<stdio.h>
main()
{
int a=0,b=1,num,c,count;
printf("Enter a number to obtain fibonacci series\n");
scanf("%d",&num);
printf("The series is\n");
printf("%d \n%d\n",a,b);
count=2;
while(count<num)
{
c=a+b;
a=b;
b=c;
printf("%d\n",c);
count++;
}
}
output:-
Enter a number to obtain fibonacci series
8
The series is
0
1
1
2
3
5
8
13
Post a Comment
If you have any doubts, Please let me know
Thanks!