Thursday, 16 October 2014

Non recursive fibonnaci program

Q:
int main()
{
  int f = 0, g = 1;
  int i;
  for(i = 0; i < 15; i++)
  {
    printf("%d \n", f);
    f = f + g;
    g = f - g;
  }
  getchar();
  return 0;
}
Answer: The function prints first 15.

No comments:

Post a Comment