The Fibonacci Sequence is the series of numbers as below :

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418,………………

Here is the C Program to understand Fibonacci Series using for loop.

Fibonacci Series using Recursion

Example of Fibonacci Series using for loop in C.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include<stdio.h> #include<conio.h> int main() { int n, first = 0, sec = 1, next, c; printf("Enter the number:\n"); scanf("%d",&n); printf("The Fibonacci series are :\n",n); for ( c = 0 ; c < n ; c++ ) { if ( c <= 1 ) next = c; else { next = first + second; first = second; second = next; } printf("%d\n",next); } return 0; } |

The output of program is :

1 2 3 4 5 6 7 |
Enter the number: 8 The Fibonacci series are : 0, 1, 1, 2, 3, 5, 8, 13 |

(Visited 14 times, 1 visits today)