/* To generate
Fibonacci Seriers (0,1,1,2,3,5,8,..) */
#include<stdio.h>
#include<conio.h>
void
main()
{
int a,b,c,i,n;
clrscr();
a=0;
b=1;
printf("Enter the range of Fibonacci
Series: ");
scanf("%d",&n);
printf("\n\nFibonacci Series:\n");
printf("\n%d",a);
printf("\n%d",b);
for(i=1;i<=n-2;i++)
{
c=a+b;
printf("\n%d",c);
a=b;
b=c;
}
getch();
}
OUTPUT
Enter
the range of Fibonacci Series: 10
Fibonacci
Series:
0
1
1
2
3
5
8
13
21
34
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.