Pages

write a program to print Fibonacci series till given number.

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, i;
    printf("Enter ending number where fibanoci series ends: ");
    scanf("%d", &fib);
    for(i=1; i<=fib; i++)
    {
             printf("Fibnocii of %d is %d.\n", i, fibn(i));
    }
    getch();
}
 

Search Box

Most Reading

Contact Form

Name

Email *

Message *