Question: Create a program using recursion with this Fibonacci sequence of numbers #incluee int main ( ) { int i , n; / / initialize first

Create a program using recursion with this Fibonacci sequence of numbers
#incluee
int main (){
int i, n;
//initialize first and second terms
int t1=0, t2=1;
//initialize the next term (3rd term)
int nextTerm = t1+ t2;
//get no. of terms from user
printf(" Enter the number of terms:");
scanf("%d,&n);
//print the first two terms t1 and t2
printf ("Fibonacci series: %d,%d,", t1, t2);
//print 3rd to nth terms
For( i=3; i<=n;++i){
printfv("%d,", nexterm);
t1=t2;
t2= nextTerm = t1+t2;
}
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!