C Program to Display Fibonacci Series

In this program, you will learn how to display Fibonacci Series upto the user provided terms. The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34. Here the next number is the sum of previous two numbers.



Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
    int i, term;
    int first=0, second=1, next;
    clrscr();
    printf("How many terms: ");
    scanf("%d", &term);
    printf("\nFibonacci series:\n");
    printf("%d, %d,", first, second);
    for(i=2; i<term; i++)
    {
        next = first + second;
        printf(" %d,", next);
        first = second;
        second = next;
    }
    getch();
}
Output
How many terms: 11

Fibonacci series:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55,