Problem: Write a c program to print the Fibonacci series up to n terms.

In the Fibonacci series, the first and second terms are 0 and 1 respectively, and every nth term is the sum of (n-2)th term and (n-1)th term.

Example: 0, 1, 1, 2, 3, 5, 8, 13 ,etc.

To print Fibonacci series in C, we need to implement the following steps:

  1. Initialize a=0 as first and b=1 as the second term.
  2. Calculate the next term c using the formula a+b.
  3. Output c and update a=b and b=c.
  4. Repeat again from step 2 till the nth term.

Here is the implementation of the steps in C.


Fibonacci series using Recursion

Fibonacci series can also be implemented using recursion.

The recursion method will return the nth term by computing the recursive(n-2)+recursive(n-1).

Since the recursive method only returns a single nth term we will use a loop to output each term of the series.


In this tutorial, we learned to print the Fibonacci series in c programming language.

Leave a Reply