# 5 – Best C program to print Fibonacci series

## C program to print Fibonacci series

Fibonacci series is a series in which numbers are in following sequences:

1, 2, 3, 5, 8, 13, 21, …

if we want to add new number in this series then we have to add last to numbers in the series.

e.g. in above series next number will be 21+13 = 34

Fn = Fn-1 + Fn-2
Following is the C Program to generate Fibonacci series.

## Logic to print Fibonacci series in C

`#include <stdio.h>int main(){    int num1, num2, i, l, temp;    printf("Enter first number : ");    scanf("%d", &num1);    printf("Enter second number : ");    scanf("%d", &num2);    printf("Enter the count of number you want to generate : ");    scanf("%d", &l);    printf("Fibonacci Series : ");    for (i=1; i<=l; ++i)    {        printf("%d, ", num1);        temp = num1 + num2;        num1 = num2;        num2 = temp;    }    return 0;}`

Output :

Enter first number : 1

Enter second number : 2

Enter the count of number you want to generate : 5

Fibonacci Series : 1, 2, 3, 5, 8,

### Connect with us on following platforms

We are aiming to explain all concepts of C in easiest terms as possible. ITVoyagers
Author