Home » C Programs » C Program For Fibonacci Series Upto N Terms

# C Program For Fibonacci Series Upto N Terms

In this program to find fibonacci series, you will learn how to display the Fibonacci sequence of the first n integers entered by the user. You must be familiar with the following C programming concepts to understand this example. Using this program to find fibonacci series

## For Loop Statement in C

In C, the for loop is used to iterate over statements or parts of programs numerous times. It is commonly used to traverse data structures such as arrays and linked lists. A “For” Loop is used to iterate over a specified block of code a predetermined number of times. A for loop is used to iterate over a series (that is either a list, a tuple, a dictionary, a set, or a string). This behaves more like an iterator method in other object-oriented programming languages than the for keyword in other programming languages.

## Fibonacci Series Definition

The Fibonacci sequence is a series of numbers that begins with a one or a zero, is followed by a one, and continues according to the rule that each number (called a Fibonacci number) is equal to the sum of the two numbers before it. Setting F0 = 0, F1 = 1, and then applying the recursive algorithm yields the Fibonacci numbers.

Fn = Fn-1 + Fn-2 to obtain the remainder. As a result, the sequence is as follows: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,… This series of Fibonacci numbers appears across mathematics and nature. Simple program to find fibonacci series for beginners in c.

## Program to Find Fibonacci Series​​​

``````//Program to Find Fibonacci Series
#include <stdio.h>
int main()
{
int i, n;
int t1 = 0, t2 = 1;
int nextTerm = t1 + t2;
printf("Enter the Number");
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;
}
``````

Program to Find Fibonacci Series​​ for Output:

Enter the Number 5
Fibonacci Series: 0, 1, 1, 2, 3,