or

ask mattrab Visit www.askmattrab.com for more academic resources.

C program to print fibonacci series

C

// To print fibonacci series

#include <stdio.h>

int main()

{

    int a, b, c, n;

    a=0;

    b=1;

    c=0;

    printf("Enter a positive number: ");

    scanf("%d", &n);


    printf("Fibonacci Series: %d, %d, ", a, b);

    c = a + b;


    while (c <= n)

{

        printf("%d, ", c);

        a = b;

        b = c;

        c = a + b;

    }


    return 0;

}

  

If you don't understand any step ( even the simplest one ) or the program fails to run, feel free to e-mail me.

Keep Exploring. ; )