Auto AdSense

Wednesday, 26 June 2013

C PROGRAM TO PRINT ALL ELEMENTS OF FIBONACCI SEQUENCE between two limits


#include<stdio.h>
#include<conio.h>

main()
{
      int pn,nn,cn,ll,ul;

      clrscr();

      printf("\n\n Enter Lower limit of fibonacci series : ");
      scanf("%d",&ll);
      printf("\n Enter Upper limit of fibonacci series : ");
      scanf("%d",&ul);

      pn = 0;
      nn = 1;
      cn = pn + nn;

      printf("\n\n FIBONACCI SERIES BETWEEN THE LIMITS %d and %d\n\n",ll,ul);

      while(cn <= ul)
      {
               cn = pn + nn;
               if(cn > ll && cn < ul)
                   printf(" %d",cn);
               pn = nn;
               nn = cn;
      }

      return 0;
}

No comments:

Post a Comment