9.16.2011

Fibonacci Series C program

Fibonacci numbers:Each Fibonacci numbers is defined to be the sum of its two immediate previous terms, where as the first two number are 0 and 1.
The Fibonacci numbers are the numbers in the following integer sequence :
0 1 1 2 3 5 8 13 21 34 55 89 144. . . . .

/*Programme to print Fibonacci numbers less than given user number*/
#include<stdio.h>
#include<conio.h>
int main()
{
 int x,y,z,num;
 printf("Enter any last number of Fibonacci series : ");
 scanf("%d",&num);
 x=0;
 y=1;
 while(num>=x)
 {
    z=x+y;
    printf("%d\t",x);
    x=y;
    y=z;
 }
 getch();
 return 0;
}

        Output of above program :

Enter last number where goes to end Fibonacci series : 70

0  1  1  2  3  5  8  13  21  34  55



Related Programs:
  1. Generate Fibonacci series using recursion method
  2. Search number is Fibonacci or not C program
  3. Flowchart for Fibonacci series

5 comments:

  1. it is very use full site ... i undershould easily and everything ...

    ReplyDelete
  2. i need algorithm for this program

    ReplyDelete
  3. your code is little wrong ,it should be z in the printf("%d\t",z) not like this printf("%d\t",x)

    ReplyDelete
  4. its wrong then...u need to change it ..z instead of x ..

    ReplyDelete
  5. i need c program to display 100 numbes

    ReplyDelete