Radical Developers welcomes all the visitors to be a member of the team. Come join us. Its all about open-source concept. All Programs are written and tested in MacOS X, Unix, Linux and may not match with the outputs of Turbo C++ in Windows

Sunday, January 9, 2011

Write a program to find out the first 25 numbers of a Fibonacci sequence. Following are the first few terms of the Fibonacci Sequence: 1 1 2 3 5 8 13 21 34 55 89…………………


Source Code :

#include<stdio.h>
void main()
{
      float a=1,b=1,c;
      int ctr=3;
      clrscr();
      printf("\nFirst 25 Fibonacci Numbers : ");
      printf("%.0f ",a);
      printf("%.0f ",b);
      while(ctr<=25)
      {
            c=a+b;
            printf("%.0f,",c);
            a=b;
            b=c;
            ctr++;
      }
      getch();
}

Output :

First 25 Fibonacci Numbers : 1,1,2,3,5,8,13,21,34,55,89,144,233,377, 610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025

1 comment:

  1. please update some java important question for beginner?????

    ReplyDelete