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;
z=x+y;
printf("%d\t",x);
x=y;
y=z;
}
getch();
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:
No comments:
Post a Comment