How to write a C Program To Generating Fibonacci Series Using Recursion in C Programming Language ?
Solution For C Program :
#include<stdio.h>
void main()
{
int a, b, j;
int fib(int);
printf("\nEnter N'th Number : "); scanf("%d", &a);
printf("\nPrinting Values of the Fibonacci Series :\n");
for(j = 0; j < a - 1; j++)
{
b = fib(j);
printf("%d,", b);
}
}
int fib(int n)
{
int x, y;
if(n == 0 || n == 1) return (1);
else
{
x = fib(n - 1);
y = fib(n - 2); return(x + y);
}
}
You may also learn these C Program/Code :
C Program To Swap Two Numbers Without Using Third Variable
Learn More :
Fibonacci
Recursion
- C Program Recursion Example
- C Program to find LCM and HCF Of Two Number Using Recursion - 3
- C Program To Convert Decimal To Binary Using Recursion
- C Program to Calculate GCD using recursion
- C Program To Calculate First Numbers Using Recursion
- C Program Finding the sum of Squares using Recursion
- Factorial Program In C Using Recursion
Generate
- How To Write a C program that generates two random numbers ?
- C program generates a random number and uses an algorithm to generate 9 other numbers.
- C Program Generates 10 Random Integers Between 0 and 99.
- C Program To Generate Multiplication Table
- C Program to Generate Specific Formats
- Write a c program to accept a string from user & generate following pattern (e.g, input "abcd")
- ACLK (32768 Hz) to generate a one second timer and toggles an LED