In mathematics, the **Fibonacci numbers** are the numbers in the sequence such as , for the every number after the first two is the sum of the two preceding ones numbers .

### Following is the example of Fibonacci series up to 6 Terms

1 | 1, 1, 2, 3, 5, 8 |

Here number is found by adding up the two numbers before it. As the number 2 is found by adding the two numbers before it (1+1) ,the number 3 is found by adding the two numbers before it as (1+2), the number 5 is by (2+3) &and so on

The sequence *F _{n}* of Fibonacci numbers is recursively represented as Fn-1 + Fn-2.

## C Program – Loops Example – Fibonacci Series up to N terms

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <stdio.h> int main() { int i, n; int a = 1, b = 0, c; printf("\n\t----------------------------------------------------------------\n"); printf("\n\t Enter the Number of Terms: "); scanf("%d", &n); printf("\n\tFibonacci Series is : "); for (i = 1; i <= n; i++) { c = a + b; printf("%d ", c); a = b; b = c; } printf("\n\t----------------------------------------------digitalpadm.com\n"); return 0; } |

In this program, Variable n is represents total number of terms , variable a and b are temp variable which represents first two number. the initial value of a is set to 1 and b to 0. variable c is to find next number.

**First Term** , value of c is a+b as (1+0) hence** 1.**

**Second Term** , new value of a is b which is 0 and new value of b is c which is 1, hence new value of c is (0+1) hence** 1**.

**Third Term** , new value of a is b which is 1 and new value of b is c which is 1 , hence new value of c is (1+1) hence** 2**.

**Fourth Term**, new value of a is b which is 1 and new value of b is c which is 2 , hence new value of c is (1+2) hence** 3.**

**Fifth Term**, new value of a is b which is 2 and new value of b is c which is 3 , hence new value of c is (2+3) hence **5.**

**Sixth Term**, new value of a is b which is 3 and new value of b is c which is 5 , hence new value of c is (2+3) hence** 8.**

so on , program calculate up to n terms.

Download Code C-program-code-Fibonacci-Series-up-to-N-terms.c (72 downloads)

Output of program