last position for fibonacci

void main()
{
int a=0,b=1,c=0,pos,i=1;
clrscr();
printf("\n Enter last position for fibonacci");
scanf("%d",&pos);
printf("\n %d\t%d",a,b);
while(i<=pos)
{
c=a+b;
printf("\t%d",c);
a=b;
b=c;
i++;
}
getch();
}

No comments:

Post a Comment