An oppurtunity opened up. It's passion, it's passion...
Tuesday, November 15, 2011
Print fibonacci series upto n: Without recursion
#include <stdio.h>
int main()
{
int first=0,second=1,next,i,n;
printf("Enter the limit: ");
scanf("%d",&n);
for(i=0; i<=n-1; i++)
{
if(i<=1)
next = i;
else
{
next = first + second;
first = second;
second = next;
}
printf("%d ",next);
}
}
No comments:
Post a Comment