C Program To Find The Fibonacci Series

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.


If You Like This Page Then Make Sure To Follow Us on Facebook, G News and Subscribe Our YouTube Channel. We will provide you updates daily.
Shares
facebook sharing button Share
twitter sharing button Tweet
whatsapp sharing button Share
telegram sharing button Share
pinterest sharing button Pin

Leave a Comment