C Program to Find Fibonacci Series

Flow Control
If-else Statement in C
Programs on if-else
Switch Case in C
Switch case Programs
Conditional Operator
While loop in C
Do-while loop in C
While vs do-while
For loop in C
Break keyword in C
Continue keyword in C
Break vs Exit in C
Goto keyword in C
☕️ Flow Control Programs
Largest in 3 Numbers
Find Grade of student
Find the absolute value
Vowel or Consonant
Leap Year Program
Simple calculator in C
Check Odd or Even 
Roots of Quadratic Equation
Find Reverse of Number
Factors of a number in C
Generate Multiplication table
Find Power of a Number
Find GCD and LCM
Find factorial of Number
Count Number of Digits
Sum of digits in Number
Sum of N Natural Numbers
Sum of Squares of Natural No.
Find Sum of Odd Numbers
Find the Sum of Series
Find Fibonacci series in C
Sum of the Fibonacci series
Sum until enters +ve numbers
Sum of max 10 no. & Skip -ve
☕️ C Conversion Programs
Celsius to Fahrenheit
Fahrenheit to Celsius
Decimal ↔ Binary
Decimal ↔ Octal
Octal ↔ Binary in C
☕️ Number Programs in C
Prime Number in C
Strong Number in C
Krishnamurthy Number
Neon Number in C
Palindrome number
Perfect Number in C
Armstrong Number
☕️ Pattern Programs in C
Pattern programs in C
Printing pattern using loops
Floyd’s triangle Program
Pascal Triangle Program
Pyramid Star Pattern in C
Diamond Pattern Programs
Half Diamond pattern in C
Print Diamond Pattern
Hollow Diamond Pattern
Diamond Pattern of Numbers

Here, we will write the C program to find the Fibonacci series, and also we will write another C program to find the nth term of the Fibonacci series.

In the Fibonacci series, the next element will be the sum of the previous two elements. The Fibonacci sequence is a series of numbers where a number is found by adding up the two numbers before it. Starting with 0 and 1, the sequence goes 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and so forth. Written as a rule, the expression is Xn= Xn-1+ Xn-2

By definition, the first two numbers in the Fibonacci sequence are either 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence, and each subsequent number is the sum of the previous two.

C Program to Find Fibonacci Series

 #include<stdio.h>
 int main()
 {
     int a=0, b=1, num, c;

     printf("Enter number of terms: ");
     scanf("%d",&num);

     for(int i=0; i<num; i++)
     {
         printf("%d\t",a);
         c = a + b; //next term
         a = b;
         b = c;
     }

     return 0;
 }

Output:-

Enter number of terms: 7
0 1 1 2 3 5 8

Enter number of terms: 10
0 1 1 2 3 5 8 13 21 34

Find Fibonacci series in a range

 #include<stdio.h>
 int main()
 {
     int a=0, b=1, range, c;

     printf("Enter the range of Fibonacci series: ");
     scanf("%d",&range);

     while( a <= range )
     {
         printf("%d\t",a);
         c = a + b;
         a = b;
         b = c;
     }

     return 0;
 }

Output:-

Enter the range of Fibonacci series: 20
0 1 1 2 3 5 8 13

Enter the range of Fibonacci series: 200
0 1 1 2 3 5 8 13 21 34 55 89 144

C program to Find Nth Fibonacci term

Sometimes, we need to find the nth Fibonacci term of the Fibonacci series.

 #include<stdio.h>
 int main()
 {
     int a=0, b=1, num, c;

     printf("Enter the term (>2): ");
     scanf("%d",&num);

     for(int i=0; i<=num; i++)
     {
         c = a + b;
         a = b;
         b = c;
     }

     printf("The Fibonacci term is: %d\t",a);

     return 0;
 }

Output:-

Enter the term (>2): 7
The Fibonacci term is: 8

Enter the term (>2): 10
The Fibonacci term is: 34

The first and second term of the Fibonacci series is 0 and 1 respectively. So, we should enter the term greater than 2.

See also:- Find the sum of Fibonacci Series, Fibonacci Series Using Recursion

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or you find anything incorrect? Let us know in the comments. Thank you!

Flow Control
If-else Statement in C
Programs on if-else
Switch Case in C
Switch case Programs
Conditional Operator
While loop in C
Do-while loop in C
While vs do-while
For loop in C
Break keyword in C
Continue keyword in C
Break vs Exit in C
Goto keyword in C
☕️ Flow Control Programs
Largest among 3 Numbers
Find Grade of student
Find the absolute value
Check Vowel or Consonant
Leap Year Program
Simple calculator in C
Check Odd or Even 
Roots of Quadratic Equation
Find Reverse of Number
Factors of a number in C
Generate Multiplication table
Find Power of a Number
Find GCD and LCM
Find factorial of Number
Count Number of Digits
Sum of digits in Number
Sum of N Natural Numbers
Sum of Squares of Natural No.
Find Sum of Odd Numbers
Find the Sum of Series
Find Fibonacci series in C
Sum of the Fibonacci series
Sum until enters +ve numbers
Sum of max 10 no. & Skip -ve
☕️ C Conversion Programs
Celsius to Fahrenheit
Fahrenheit to Celsius
Decimal ↔ Binary
Decimal ↔ Octal
Octal ↔ Binary in C
☕️ Number Programs in C
Prime Number in C
Strong Number in C
Krishnamurthy Number
Neon Number in C
Palindrome number
Perfect Number in C
Armstrong Number
☕️ Pattern Programs in C
Pattern programs in C
Printing pattern using loops
Floyd’s triangle Program
Pascal Triangle Program
Pyramid Star Pattern in C
Diamond Pattern Programs
Half Diamond pattern in C
Print Diamond Pattern
Hollow Diamond Pattern
Diamond Pattern of Numbers

Leave a Comment

Your email address will not be published. Required fields are marked *