Thursday, 16 November 2017

C Program to Generate Fibonacci Series


Code:

#include stdio.h

void main()
{
    int  fib1 = 0, fib2 = 1, fib3, limit, count = 0;

    printf("Enter the limit to generate the Fibonacci Series \n");
    scanf("%d", &limit);
    printf("Fibonacci Series is ...\n");
    printf("%d\n", fib1);
    printf("%d\n", fib2);
    count = 2;
    while (count < limit)
    {
        fib3 = fib1 + fib2;
        count++;
        printf("%d\n", fib3);
        fib1 = fib2;
        fib2 = fib3;
    }
}


Output:

Enter the limit to generate the Fibonacci Series
6
Fibonacci Series is ...
0
1
1
2
3
5



More C Programs:














100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...