top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

C: All fibonacci values between given two input values?

+1 vote
289 views

Input: 10 400
output: 13 21 34 55 89 144 233 377

posted Nov 21, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
main()
{
  int start,end,a,b,c;

  // get start and end from user
  a=0;
  b=1;
  c=a+b;

  while(c<start)
  {
    a=b;
    b=c;
    c=a+b;
  }

  do
  {
    printf("%d\n",c);
    a=b;
    b=c;
    c=a+b;
  } while(c<end);

}
answer Nov 23, 2014 by Krishnan Goskan
Similar Questions
+3 votes

Given input as a string, return an integer as the sum of all numbers found in the string

Input: xyzonexyztwothreeeabrminusseven
Output : 1 + 23 + (-7) = 17

+1 vote

Write your own rand function which returns random numbers in a given range(input) so that the numbers in the given range is equally likely to appear.

+2 votes
...