Monday 7 July 2014

FIBONACCI SERIES( using for loop )

FIBONACCI SERIES( using for loop )


#include<stdio.h>
#include<conio.h>
void main();
{
int n,first=0,second=1,next,c;
clrscr( );
printf("enter no. of terms");
scanf("%d",&n);
for(c=0;c<n;c++)
{
if(c<=1)
{
next=c;
}
else
{
next=first+second;
first=second;
second=next;
}
}
printf("%d",n);
getch();
}

No comments:

Post a Comment