• In Fibonacci series the first two numbers in the Fibonacci sequence are 0 and 1 and each subsequent number is the sum of the previous two. For example Fibonacci series is 0, 1, 1, 2, 3, 5, 8,13, 21
  • C Program to Display Fibonacci Sequence 
  • Fibonacci series means next number will be generated as sum of previous two numbers.

#1: C example program on Fibonacci series

  1. #include <stdio.h>

  2. void main()
  3. {
  4.     int  fib1 = 0, fib2 = 1, fib3, limit, count = 0;

  5.     printf("Enter the limit to generate the Fibonacci Series \n");
  6.     scanf("%d", &limit);
  7.     printf("Fibonacci Series is ...\n");
  8.     printf("%d\n", fib1);
  9.     printf("%d\n", fib2);
  10.     count = 2;
  11.     while (count < limit)
  12.     {
  13.         fib3 = fib1 + fib2;
  14.         count++;
  15.         printf("%d\n", fib3);
  16.         fib1 = fib2;
  17.         fib2 = fib3;
  18.     }
  19. }
Output:
  1. Enter the limit to generate the Fibonacci Series
  2. 20
  3. Fibonacci Series is ...
  4. 0
  5. 1
  6. 1
  7. 2
  8. 3
  9. 5
  10. 8
  11. 13
  12. 21
  13. 34
  14. 55
  15. 89
  16. 144
  17. 233
  18. 377
  19. 610
  20. 987
  21. 1597
  22. 2584
  23. 4181


Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu