Fibonacci Series Program in C Using Function

Fibonacci series program in c using function. In this program we can find a number is a Fibonacci number or not in c programming using functions.

Fibonacci Series Definition in C

The Fibonacci sequence is a set of numbers that begins with a one or a zero and ends with a one, following the rule that each number (called a Fibonacci number) is equal to the sum of the two numbers before it.

The golden ratio, which is represented by the Greek letter phi, is approximately 1.618.

The famous “Fibonacci numbers” are the best approximation of the golden ratio.

Fibonacci numbers are a never-ending sequence that begins with 0 and 1 and continues by adding the two numbers before it.

While Loop in C

A “While” Loop is used to repeat a block of code an unknown number of times until it meets a condition.

A while loop is a control flow statement in most computer programming languages that allows code to be executed repeatedly based on a given Boolean condition. The while loop is similar to a looping if statement.

Fibonacci Series Program in C Using Function

#include<stdio.h>
void func(int range)
{
int a=0, b=1, c;
while (a<=range)
{
printf("%d\t", a);
c = a+b;
a = b;
b = c;
}
}
int main()
{
int range;
printf("Enter Range");
scanf("%d", &range);
printf("Fibonacci Series Numbers are\n");
func(range);
return 0;
}

Output:

Enter Range 5

Fibonacci Series Numbers are

0       1       1       2       3       5