C Program To Find The Fibonacci Series: In this program we will use Fibonacci concept (the Fibonacci sequence, in which each number is the sum of the two preceding ones), and for loop to find the series.
Code for C program To Find The Fibonacci Series
#include<stdio.h>
#include<conio.h>
int main()
{
int i, n;
int t1 = 0, t2 = 1;
int nextTerm = t1 + t2;
printf("Enter the number of terms: ");
scanf("%d", &n);
printf("Fibonacci Series: %d, %d, ", t1, t2);
for (i = 3; i <= n; ++i)
{
printf("%d, ", nextTerm);
t1 = t2;
t2 = nextTerm;
nextTerm = t1 + t2;
}
return 0;
}
Output
Enter the number of terms: 10
Fibonacci Series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34.
Read: C program to find squares of the summation of n numbers.