Program to print the Fibonacci Series using Function

0 Suresh Chand June 2, 2021

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


This is the algorithm of program to find fibonacci Series

Step 1: Start

Step 2: Initialize variables i, n, t1 = 0, t2 = 1

Step 3: Initialize variable and assign t1 + t2

Step 4: Take input from the user and assign to variable n

Step 5: Assign i = 1

Step 6: Repeat this step until i <= n

           Step 6.1: Print nextTerm variable

          Step 6.2: t1 = t2

         Step 6.3: t2 = nextTerm

         Step 6.4: nextTerm = t1 + t2

Step 7: End


This is the flowchart of program to find fibonacci Series

Flowchart : Program to print the Fibonacci Series using Function

CODE: Fibonacci Series using Function

We will print fibonacci Series


//Function Prototype
void fibonacci(int num);

void main(){

    int num = 0;

    printf("Enter number of terms : ");
    scanf("%d", &num);

    //Function to print Fibonacci Series

//Function to print Fibonacci Series
void fibonacci(int num){

    int a, b, c, i = 3;
    a = 0;
    b = 1;

    if(num == 1)

    if(num >= 2)

    while(i <= num){

        c = a+b;
        printf("\t%d", c);
        a = b;
        b = c;

Download Application: Learn C Programming with Live Compiler

The output of above program is

Enter number of terms : 10
0       1       1       2       3       5       8       13      21      34
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