Here is a C language program to print Fibonacci series. Fibonacci series is the series where a series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers.
The simplest is the series 1, 1, 2, 3, 5, 8, etc.
Print Fibonacci Series C Program
// c program to print fibonacci series
#include <stdio.h>
void fibonacci(int limit){
int f0 = 0;
int f1 = 1;
int f2;
printf("\nYour Fibonacci series with %d elements is...",limit+1);
while(limit>1){
if(f0 == 0 && f1 == 1){
printf("\n%d,%d,",f0,f1);
}
f2 = f1 + f0;
f0 = f1;
f1 = f2;
printf("%d,",f2);
limit--;
}
}
int main(){
int limit;
printf("Enter series limit(1 - ∞):");
scanf("%d",&limit);
fibonacci(limit);
return 0;
}
Input & Output
Enter series limit(1 - ∞):10
Your Fibonacci series with 11 elements is...
0,1,1,2,3,5,8,13,21,34,55,