/* Fibonacci Series : Next number is the sum of previous two numbers. The first two numbers of fibonacci series are 0 and 1. */
#include <stdio.h>
int main()
{
int n, c, a = 0, b = 1, i;
printf("Enter the number of terms: ");
scanf("%d", &n);
printf("The Fibonacci Series upto first %d terms is.....\n", n);
for(i = 0; i < n; i++){
c = a + b;
b = a;
a = c;
printf("%d ", b);
}
return 0;
}
Comments
Post a Comment