Sunday, 24 December 2017

C Program to print fibonacci series within given range

Ques: Program to print fibonacci series of given range such that series last number will be less than or equal to given no.

#include<stdio.h>
int main( )
{
   int n, a=1, b=1, temp;
   
   printf("Enter the number");
   scanf("%d",&n);

  printf("Fibonacci series is %d %d ", a,b);


  while(a+b<=n)

    {
       temp=a;
       a=b;
       b=a+temp;
       printf("%d ",b);
    }
return 0;
}



No comments:

Post a Comment

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...