Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program to generate Fibonacci series.
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int i;
- long a, b=0, c=1, d=1;
- clrscr();
- printf("Enter the number of terms of fibnoacci series to display: ");
- scanf("%li", &a);
- printf("The first %li terms of fibonacci series are: ", a);
- for(i=0;i<=a;i++) {
- if(i <= 1)
- d = i;
- else {
- d=b+c;
- b=c;
- c=d;
- }
- printf("%li ", d);
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment