Program to print Fibonacci Series

0 June 21, 2021

In this example, We will learn a Program to print Fibonacci Series. Before that, You must have knowledge of the following topics.

Make sure you have knowledge of Function.

Download Application: Learn C Programming with Live Compiler


The algorithm of program is

Step 1: Start
Step 2: Declare variables i, n, t1, and t2
Step 3: Assign t1 = 0 and t2 = 1
Step 4: Declare variable nextTerm and Assign t1 + t1 to nextTerm
Step 5: Take input from user and store in n
Step 6: Repeat this step until i <= n
        Print nextTerm
        t1 = t2
        t2 = nextTerm
        nextTerm = t1 + t2
Step 7: End


The flowchart of program is

Flowchart : Program to print Fibonacci Series

CODE: Program to print Fibonacci Series

Now, We will see the main code to print Fibonacci series of any number

#include <stdio.h>

int main() {
    int i, n, t1 = 0, t2 = 1;
    int nextTerm = t1 + t2;
    printf("Enter the number of terms: ");
    scanf("%d", &n);
    printf("Fibonacci Series: %d, %d, ", t1, t2);

    for (i = 1; i <= n; ++i) {
        printf("%d, ", nextTerm);
        t1 = t2;
        t2 = nextTerm;
        nextTerm = t1 + t2;

    return 0;

The output of above program is

Enter the number of terms: 5
Fibonacci Series: 0, 1, 1, 2, 3, 5, 8,
Notify of
Inline Feedbacks
View all comments

Join Our Newsletter Now

Get the latest tutorials, examples and projects updates.



Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Disable Ad Block

Want Same System