/* A program to Print Fibonacci Series */
#include<stdio.h>
int main()
{
int n, term_1 = 0, term_2 = 1, next_term, c;
printf("Enter the number of terms in Fibonacci series:");
scanf("%d",&n);
printf("\nFirst %d terms of fibonacci series are:\n",n);
for ( c = 0 ; c < n ; c++ )
{
if ( c <= 1 )
next_term = c;
else
{
next_term = term_1 + term_2;
term_1 = term_2;
term_2 = next_term;
}
printf("%d\n",next_term);
}
return 0;
}
No comments:
Post a Comment