Programming in "C‟ | Write a „C‟ program to display fibbonacci series using recursion.

Write a „C‟ program to display fibbonacci series using recursion.

(Note: Any other correct logic shall be considered).

#include<stdio.h>

main()

int fibonaci(int);

 int n, i = 0, c;

 scanf("%d", &n);

 printf("Fibonacci series terms are:\n");

 for (c = 1; c <= n; c++)

{

    printf("%d\n", fibonaci(i));

      i++;

 }

 getch(); 

}

int fibonaci(int n)

{

   if (n == 0 || n == 1)

    return n;

    else

    return (fibonaci(n-1) + fibonaci(n-2));

Post a Comment

0 Comments