Friday 16 September 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

No comments:

Post a Comment