Fibonacci series
/*WAP to generate
the fibonacci series*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,n;
a=1,b=2;
clrscr();
printf("enter
the value of n:");
scanf("%d",&n);
printf("%d
%d ",a,b);
while(n>2)
{
c=a+b;
printf("%d
",c);
a=b;
b=c;
n--;
}
getch();
}
OUTPUT:
enter the value
of n:5
1 2 3 5 8
No comments:
Post a Comment