Fibonacci series in a given range


Program to print those terms of fibonacci series which are between 1 and n


#include <stdio.h>
#include <conio.h>
void main()
{
  long  a=1 ,b=1 , c ;
  int  i , n ;

  printf("Enter n: ") ;
  scanf("%d" , &n) ;

  printf("Fibonacci series is as shown: \n") ;

  if(n==1)
    printf("% ld \n %ld \n" , a , b) ;
  else if(n>1)
  {
	printf("% ld \n %ld \n" , a , b) ;
	c=a+b ;
     do
     {
       printf(" %ld \n" , c) ;
       a=b ;
       b=c ;
       c=a+b ;
     }
     while(c<=n) ;
  }
}

Output :

Output