Utopper SkillUtopper Skill
  • Programming
    • Programming Examples
  • Interview Questions
    • DevOps Interview Questions
    • Android Interview Questions
  • How to
  • Tools
  • Top 10
  • Book Summaries
Reading: Fibonacci Series in C
Share
Utopper SkillUtopper Skill
Search
  • Book Summaries
  • Programming Examples
  • C Programming Example
  • Interview Question
  • How to
  • Top 10
Follow US
Utopper Skill > Programming Examples > C Programming Example > Fibonacci Series in C
Programming ExamplesC Programming Example

Fibonacci Series in C

Utopper Skill Team
By Utopper Skill Team Last updated: March 1, 2023
Share
6 Min Read
Fibonacci Series in C
SHARE
Table of Content
Fibonacci Series in CWhat is Fibonacci Series?Approach to print Fibonacci Series in C LanguagePseudo Code to Print Fibonacci Series in C LanguageC Program to print Fibonacci seriesThe output will look something like this:

Fibonacci Series in C

The Fibonacci series in C is a sequence of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1.

What is Fibonacci Series?

The Fibonacci series is a sequence of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1.

The Fibonacci sequence is named after the Italian mathematician Leonardo of Pisa, who was also known as Fibonacci. He introduced the series to the Western mathematics in his book Liber Abaci, which he wrote in 1202.

The Fibonacci series is an example of a recursive sequence, which means that the next number in the series is calculated by adding the previous two numbers. The first few numbers in the series are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and so on. It is also closely related to the Golden Ratio and occurs in many natural phenomena, such as the branching of trees and the arrangement of leaves on a stem.

Approach to print Fibonacci Series in C Language

Here is one approach to print the Fibonacci series in C:

  1. Include the stdio.h header file to use the printf and scanf functions.
  2. In the main function, declare three variables: i, n, t1, t2, and nextTerm.
  3. Prompt the user to enter the number of terms they want in the series and store it in the variable n.
  4. Initialize t1 and t2 to 0 and 1 respectively. These will be the first two terms of the series.
  5. Use a for loop to iterate from 1 to n. In each iteration, print the value of t1, which is the current term in the series.
  6. Calculate the next term in the series by adding t1 and t2 and store it in the variable nextTerm.
  7. Update the values of t1 and t2 for the next iteration by setting t1 to the value of t2 and t2 to the value of nextTerm.
  8. Repeat steps 5 to 7 for all the iterations of the for loop.
  9. Finally, return 0 from the main function to indicate successful execution of the program.

This is just one of the possible approaches to print the Fibonacci series in C. There are many other ways to accomplish this task, each with its own advantages and disadvantages.

Pseudo Code to Print Fibonacci Series in C Language

// Pseudo code for printing Fibonacci series in C

// Step 1: Include the stdio.h header file
#include <stdio.h>

// Step 2: Define the main function
int main()
{
    // Step 3: Declare variables for iteration, number of terms, and the current and next terms in the series
    int i, n, t1, t2, nextTerm;

    // Step 4: Prompt the user to enter the number of terms they want in the series
    printf("Enter the number of terms: ");
    scanf("%d", &n);

    // Step 5: Initialize the first two terms in the series
    t1 = 0;
    t2 = 1;

    // Step 6: Use a for loop to iterate from 1 to the number of terms
    for(i = 1; i <= n; i++)
    {
        // Step 7: Print the current term in the series
        printf("%d ", t1);

        // Step 8: Calculate the next term in the series
        nextTerm = t1 + t2;

        // Step 9: Update the current and next terms for the next iteration
        t1 = t2;
        t2 = nextTerm;
    }

    // Step 10: Return 0 from the main function to indicate successful execution
    return 0;
}

C Program to print Fibonacci series

#include <stdio.h>

int main()
{
    int i, n, t1 = 0, t2 = 1, nextTerm;

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

    printf("Fibonacci Series: ");

    for (i = 1; i <= n; ++i)
    {
        printf("%d, ", t1);
        nextTerm = t1 + t2;
        t1 = t2;
        t2 = nextTerm;
    }

    return 0;
}

This C program will prompt the user to enter the number of terms they want in the Fibonacci series, and then print the series using a for loop. The initial values of t1 and t2 are set to 0 and 1 respectively, the same as the Fibonacci series. And with each iteration of the loop, the next term in the series is calculated and printed, and the values of t1 and t2 are updated for the next iteration.

The output will look something like this:

Enter the number of terms: 8
Fibonacci Series: 0, 1, 1, 2, 3, 5, 8, 13,

Please Remember that the exact output will depend on the value entered by the user for the number of terms.

Check Out Other Programs :

Palindrome Number in C
TAGGED:C Program ExamplesFibonacci Series
Share This Article
Facebook Twitter Whatsapp Whatsapp Telegram Copy Link Print
Previous Article Palindrome Number in C Palindrome Number in C
Next Article Prime Number in C Prime Number in C
Most Popular
Learn C Programming (Basic to Advanced)
Two Dimensional Array in C
Utopper Skill Author By Utopper Skill Author
Book Summary of Why Nobody Told Me This Before By Dr. Julie Smith
Book Summary of Why Nobody Told Me This Before? By Dr. Julie Smith
Utopper Skill Author By Utopper Skill Author
Learn C Programming (Basic to Advanced)
Pointer to an Array in C
Utopper Skill Author By Utopper Skill Author
Learn C Programming (Basic to Advanced)
Structure Padding in C
Utopper Skill Author By Utopper Skill Author
Book Summary of How to Win Friends and Influence People by Dale Carnegie
Book Summary of How to Win Friends and Influence People By Dale Carnegie
Utopper Skill Author By Utopper Skill Author

You Might Also Like

C++ Program To Print Prime Numbers From 1 To N
C Programming ExampleProgramming Examples

C++ Program To Print Prime Numbers From 1 To N

11 Min Read
C Program to Print Your Own Name
Programming ExamplesC Programming Example

C Program to Print Your Own Name with Example

2 Min Read
C Program To Convert Fahrenheit To Celsius
C Programming ExampleProgramming Examples

C Program To Convert Fahrenheit To Celsius

5 Min Read
C Program To Find LCM of Two Numbers
Programming ExamplesC Programming Example

C Program To Find LCM of Two Numbers

6 Min Read

Mail : [email protected]

Privacy Policy | DISCLAIMER | Contact Us

Learn

  • learn HTML
  • learn CSS
  • learn JavaScript

Examples

  • C Examples
  • C++ Examples
  • Java Examples

Study Material

  • Interview Questions
  • How to
  • Hosting
  • SEO
  • Blogging

 

© 2024 : UTOPPER.COM | Owned By : GROWTH EDUCATION SOLUTIONS PRIVATE LIMITED
Welcome Back!

Sign in to your account

Lost your password?