Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int n, a=0, b=1, c=0;
clrscr();
printf("Enter any Number : ");
scanf("%d", &n);
printf("Fibonacci series : ");
printf("\n%d\t%d", a,b);
while(n>2)
{
c=a+b;
printf("\t%d", c);
a=b;
b=c;
n--;
}
getch();
}
Output:
Enter any Number : 15
Fibonacci series :
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
Next Topic :
Previous Topic :
No comments:
Post a Comment