top of page
Wave
Cactus%20Plant_edited.jpg

FIBONACCI SERIES USING RECURSION

#include<stdio.h>
void call_fibo(int x)
{
    static int i;
    if(i>=x)
        return;
    i=i+1;
    printf("%d ",fibo(i));
    call_fibo(x);
}
int fibo(int n)
{
    if(n==0||n==1)
        return n;
    else
        return(fibo(n-1)+fibo(n-2));
}
int main()
{
    int x;
    printf("how many fibonacci terms you want: ");
    scanf("%d",&x);
    printf("\nThe fibonacci terms are : ");
    call_fibo(x);
    printf("\n");
    return 1;
}

Subscribe Form

Thanks for submitting!

  • Facebook
  • YouTube
  • Instagram
  • Twitter

©2020 by Abhisek Midya ( A18 )

bottom of page