Fibonacci Series in C Program

Fibonacci series in c program. This is the basic set of the program in the c programming language. This fibonacci number series program in any language is the basic and next step to the mathematical program in any programming language.

#include <stdio.h>
int main() 
{
int i, n, t1 = 0, t2 = 1, next;
printf("Enter the number");
scanf("%d", &n);
printf("Fibonacci Series");
for (i = 1; i <= n; ++i)
{
printf("%d, ", t1);
next = t1 + t2;
t1 = t2;
t2 = next;
}
return 0;
}

 

Output

Enter the number 6

Fibonacci Series 0, 1, 1, 2, 3, 5,

Fibonacci Series in C Program

Fibonacci numbers are a mathematical sequence established by the Italian mathematician “Fibonacci” in the 13th century that is used to generate technical indicators. By adding the preceding two numbers, a sequence of numbers starting with zero and one is formed.

Cauliflower contains a Fibonacci spiral. Pineapples and bananas are also rich in Fibonacci numbers. Bananas have three or five flat sides, while pineapple scales contain Fibonacci spirals in groups of eight, thirteen, and twenty-one. The Fibonacci sequence may be found inside the fruit of many plants.

For Loop in C Program

A for loop is a type of repetition control structure that allows us to write a loop that is executed a set number of times. The loop allows us to perform a n number of steps in a single line. A for-loop (or simply for loop) is a control flow statement in computer science that specifies iteration and allows code to be executed repeatedly.