Print Fibonacci Series using Recursion | C program :

Write a C Program to Print Fibonacci series user given range using recursion , C program :

Code:


#include<conio.h>
#include<stdio.h>
void main()
{
    int fibo(int);
    int n,i;
    printf("Enter the range of fibo:\n");
    scanf("%d",&n);
    for(i=0;i<=n;i++)
        printf("%d\t",fibo(i));
    getch();
}
int fibo(int i)
{
    if(i==0 || i==1)
        return 1;
    else
        return (fibo(i-1)+ fibo(i-2));
}

Output:





Comments

Popular posts from this blog

Print name in a pattern | name as abbreviation | C-Program