Tuesday, 15 February 2022

Fibonacci Sequence in C language

 #include <stdio.h>

int main()
{
    int i;
    int a[20];

    a[0] = 1;
    a[1] = 1;
    printf("The following is the Fibonacci Sequence");
    for (i = 0; i < 12; i++)
    {
        a[i + 2] = a[i] + a[i + 1];

        printf("%d\n", a[i]);
    }
    return (0);
}

No comments:

Post a Comment