Program to display fibonacci series of given number
Program to display febonacci series of given number
| 1 |
/*Programme for febonacci series*/ |
| 2 |
#include <stdio.h> |
| 3 |
#include <conio.h> |
| 4 |
void fibonacci(int p, int pp,int num) |
| 5 |
{ |
| 6 |
int febo,j; |
| 7 |
j=num; |
| 8 |
|
| 9 |
febo=p+pp; |
| 10 |
if (febo<num) |
| 11 |
{ |
| 12 |
printf(" |
| 13 |
%d",febo); |
| 14 |
pp=p; |
| 15 |
p=febo; |
| 16 |
febo=p+pp; |
| 17 |
febonacci(p,pp,j); |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
void main() |
| 24 |
{ |
| 25 |
int num; |
| 26 |
printf("Enter a number to generate Fibonacci series: "); |
| 27 |
scanf("%d",&num); |
| 28 |
fibonacci(0,1,num); |
| 29 |
getch(); |
| 30 |
} |