WAP to Print Fibonacci Series using Recursion.

#include<stdio.h>

#include<math.h>

int main()

{

    int a,b,c;

    printf("enter the number = ");

    scanf("%d",&a);

    for(c=0;c<a;c++)

    {

        b=0;

        b=fibonacci(c);

        printf("\n%d",b);

    }

}

int fibonacci(int c)

{

    if(c==0)

    {

        return 0;

    }

    else if(c==1)

    {

        return 1;

    }

    else

    {

        return (fibonacci(c-1)+fibonacci(c-2));

    }

}
WAP to Print Fibonacci Series using Recursion. WAP  to Print Fibonacci Series using Recursion. Reviewed by Unknown on 03:38 Rating: 5

No comments:

Powered by Blogger.