Fibonacci Series in C Program – Today, We are going to share about a program for fibonacci series in c. Fibonacci series is a sequence of numbers in which next number in the sequence is obtained by adding previous two numbers. For example 0, 1, 1, 2, 3, 5, 8, 13. Below I have shared C program to implement it. We have mentioned each and every required thing for C program to find fibonacci series up to n terms.
Basic C programming, While loop
Fibonacci series is a series of numbers where the current number is the sum of previous two terms.
For Example: 0, 1, 1, 2, 3, 5, 8, 13, 21…
Fibonacci series algorithm
If you look to the given series very carefully you will find a specific pattern i.e. the current number is the sum of previous two numbers.
Fibonacci series : 0, 1, 1, 2, 3, 5, 8, 13, 21…
1 is the sum of 0 + 1
2 is the sum of 1 + 1
3 is the sum of 2 + 1
5 is the sum of 3 + 2
and so on….
Lets suppose the first number as a i.e. a = 0
Second number as b i.e. b = 1
And lets suppose c as our current number in Fibonacci series also initialize the value with 0 i.e. c = 0
Now Fibonacci series algorithm is simple and contains only four steps.
Step 1: Print the value of c.
Step 2: a = b.
Step 3: b = c.
Step 4: c = a + b.
Read more interesting facts about Fibonacci series.
Program to print fibonacci series
* C program to print Fibonacci series up to n terms
int a, b, c, i, n;
* Reads a number from user
printf(“Enter value of n to print Fibonacci series : “);
a = 0;
b = 1;
c = 0;
for(i=1; i<=n; i++)
printf(“%d, “, c);
Happy Coding. If there is any update we will update here. You can also bookmark this page for more details about the C program to find fibonacci series.