Sunday, October 16, 2011

Fibonacci Series

#include<stdio.h>
#include<conio.h>
void main ()
{
      int a,b,c,n;
      clrscr();
      a=0;b=1;c=1;
      printf("Enter the last number of the series");
      scanf("%d",n);
      printf("%d\n%d",a,b);
      while (c<n)
      {
           c=a+b;
           printf("\n%d",c);
           a=b;
           b=c;
       }
getch ();
}

No comments:

Post a Comment