0% found this document useful (0 votes)
25 views1 page

#Include #Include Int Void Int: / Title:Program To Print Fibonacci Series Using Recursion.

This program uses recursion to print the Fibonacci series. It takes user input for the number of terms to print. It defines two global variables f1 and f2 to track the first two numbers of the series. The fibonacci function recursively calls itself, passing the input minus 1, to calculate the next term and print the series up to the user input number of terms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views1 page

#Include #Include Int Void Int: / Title:Program To Print Fibonacci Series Using Recursion.

This program uses recursion to print the Fibonacci series. It takes user input for the number of terms to print. It defines two global variables f1 and f2 to track the first two numbers of the series. The fibonacci function recursively calls itself, passing the input minus 1, to calculate the next term and print the series up to the user input number of terms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

/* Title:Program to print Fibonacci series using

recursion.
*/
#include<conio.h>
#include<stdio.h>
int f1=0,f2=1;
void main()
{
int n;
clrscr();
printf("Enter the level of the series:");
scanf("%d",&n);
fibonacci(n);
getch();
}
int fibonacci(int n)
{
int temp;
if(n<2)
{
f1=0;
f2=1;
}
else
{
fibonacci(n-1);
temp=f2;
f2=f1+f2;
f1=temp;
}
printf("%d\t",f1);
return;
}

You might also like