Fibonacci Series C Program

By | September 21, 2015

Let us learn how to print Fibonacci series in C programming language. It is important that we should know how a for loop works before getting further with the fibonacci sequence code.

What is a Fibonacci sequence?

A Fibonacci series is a sequence of numbers in which the next number is found by adding the previous two consecutive numbers.

Note: The first two digits in a Fibonacci series is always 0 and 1.

The first digit in a Fibonacci sequence is 0 and the second digit as 1. The next digit or the third element is dependent upon the two preceding elements. The third element is, therefore, the sum of the previous two digits. This addition of previous two digits continues till the limit defined by the user.

The third element is, therefore, the sum of the previous two digits. This addition of previous two digits continues till the limit defined by the user.


0 1 1 2 3 5 8

Note: This code to display Fibonacci series in C programming has been compiled with GNU GCC compiler and developed with gEdit Editor in Linux Ubuntu operating system.

Method 1: Print Fibonacci Series in C Programming using For Loop

Method 2: C Program To Generate Fibonacci Sequence using While Loop

Method 3: C Program To Print Fibonacci Sequence using Functions


Learn How To Print Fibonacci Series in C Programming

There’s a trick with the Fibonacci sequence. The consecutive terms in a fibonacci sequence can be made to convert miles to kilometers. This has been properly demonstrated in Zeckendorf’s Theorem.


Let us take 5 and 8, which are consecutive terms in a fibonacci series.  But, 5 Miles = 8 Kilometres. Similarly, 8 Miles = 13 kilometres.


In case you get any compilation errors in the above code to print fibonacci sequence in C programming using while loop and for loop or if you have any doubts about it, let us know about it in the comment section below.

Recommended Programs
C Program To Print Fibonacci Series using For Recursion
C Program To Calculate Sum of Digits of a Number
C Program To Find Narcissistic Number
Print A Christmas Tree in C Programming
C Program For Binary Search Algorithm using Functions
C Program To Find Magic Number
C Program To Multiply Two Numbers without Multiplication Operator
C Program To Convert Decimal To Octal Number
C Program For Travelling Salesman Problem
C Program To Count Trailing Zeros in an Integer using Loops
100+ C Programs For Programming Interviews

25 thoughts on “Fibonacci Series C Program

    1. Tushar Soni Post author

      You’re welcome Shanmukha. Our main reason to post multiple methids is to help the students understand the differences between them which will help then to clear basic concepts.

  1. Akshay Patwardhan

    Can we solve Fibonacci Series C Program using Recursion method?

    1. Tushar Soni Post author

      Yes Akshay. Almost all the For Loops, While Loops can be converted into Recursion methods. You just need to understand Recursion properly.

  2. Nayan Patil

    Is this a common interview question? My teachers told that it is frequently asked in interviews.

    1. Tushar Soni Post author

      It depends on the interviewer. But, you should understand the logic of Fibonacci Series. It is not that difficult.

  3. Rajesh Makhija

    Thanks. You have made this logic for Fibonacci series quite simple to understand.

  4. Ashish Kediya

    When we have written this code
    first = second;
    second = third;
    then why do we need to take the value of first and second as 1 and 0 at initialization in this fibonacci c program?

  5. Krishna Kunal

    Thanks for the fibonacci series logic. This is too good program!

  6. Vikash Kumar

    Instead of hard coding the first and second values of the fibonacci sequence, why not take the values from the user itself. Just in case he/she wants to begin the fibonacci sequence after a certain number, it would be much easier to code it in C language.

  7. Diksha Tandon

    Thanks for this. It is so nice of you to code and publish different methods for every given program. Keep it up.

  8. Prasad Reddy

    Why don’t you use recursion method to print the fibonacci series. The code becomes much easier and simpler.

  9. Gurpreet Sodhi

    What is a Tribonacci Series? Is it something related to Fibonacci sequence?

    1. Kaustubh Bansod

      Yup. In fibonacci sequence, you take two digits’ sum as the next digit. However, in tribonacci series, you take first digits’s sum for the next digit.


Let's Discuss