Wednesday, October 6, 2010

C Program to generate Fibonacci sequence

//to generate fibonacci
int main()
{
int ft=-1,st=1,nt,n,c;
printf("enter any number \n");
scanf("%d",&n);
for(c=1;c<=n;c++)
{
nt=ft+st;
ft=st;
st=nt;
printf("%d\t",nt);
}
system("pause");
return 0;
}

No comments:

Post a Comment

Google+ Followers