» » Fibonacci series in c without recursion

# Fibonacci series in c without recursion

• 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

#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