Pages

Write a program to print Fibonacci series using recursion.

Friday, 7 June 2013

#include <stdio.h>
#include <conio.h>
int fibn(int n)
{
      int a, b, c;
      if(n==1 || n==2)
      return(n-1);
      a=fibn(n-1);
      b=fibn(n-2);
      c=a+b;
      return c;
}
int main()
{
    int fib;
    printf("Enter number: ");
    scanf("%d", &fib);
    printf("Fibnocii of %d is %d.", fib, fibn(fib));
    getch();
}
 

Search Box

Most Reading

Contact Form

Name

Email *

Message *