Question

Would you help me for this small HW Assignment please; This project is to practice recursion....

Would you help me for this small HW Assignment please;

This project is to practice recursion.

The resursive function

Given f(0) = c and f(n) = f(n-1)*f(n-1) + c for n>0, where n is an integer and c is a floating point number, please get n and c from the keyboard and calculate and display f(n) if f(n) < 10000.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
//C code
#include <stdio.h>

float f(int n, float c){
   if(n == 0){
      return c;
   }
   else{
      float res = f(n-1, c);
      return res * res + c;
   }
}


int main(){
   float c;
   int n;
   
   printf("Enter value for c: ");
   scanf("%f",&c);
   
   printf("Enter value for n: ");
   scanf("%d",&n);
   
   printf("f(n) = %f\n",f(n, c));
   
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
Would you help me for this small HW Assignment please; This project is to practice recursion....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the code in java programming language To get some practice with recursion. You can do...

    Write the code in java programming language To get some practice with recursion. You can do all this in one driver program. Write a recursive method to compute the result of the Fibonacci sequence: Fibonacci(N) = Fibonacci(N -1) + Fibonacci(N-2) N == 0 is 0 N == 1 is 1 Testing: Display the result for Fibonacci(N) and the number of function calls for N = 2, 5 and 10.

  • This is a c programming problem. Would you please help me to write this problem??? I...

    This is a c programming problem. Would you please help me to write this problem??? I really appreciate it if you add comments for explanation step by step. Thank you. Reverse a Doubly linked list using recursion: Given a doubly linked list. Reverse it using recursion. Original Doubly linked list: next pointer - DDHIHI Null prev painter Reversed Doubly linked list: next pointer Start Pointer Null prev pointer Include: a) A struct for a node of the doubly linked list....

  • This assignment is a rsa project. please help me with it? Generate two prime numbers at...

    This assignment is a rsa project. please help me with it? Generate two prime numbers at least 1 million. These are p and q. n = pxq. Show how and show p and q * Find d and e . Show how and show d and e. * Encrypt message 100. use the above results. show this number. Programming language! C++ Please add some comments to the program. Thank you

  • Hi! Please help me on this question #41. Thank you so much! (by giving the p.m.f....

    Hi! Please help me on this question #41. Thank you so much! (by giving the p.m.f. or p.d.f.) whose the cumulative distribution function F(t) satisfies F(n) = 1 - 1 for each positive integer n. Exercise 3.41. We produce a random real number X through the following two- stage experiment. First roll a fair die to get an outcome Y in the set {1,2,...,6}. Then, if Y = k, choose X uniformly from the interval (0, k]. Find the cumulative...

  • Please help me with this program. Using C++ (printf & scanf) statements. Thank you. ASSIGNMENT: Write...

    Please help me with this program. Using C++ (printf & scanf) statements. Thank you. ASSIGNMENT: Write a program to ask the user for a number that includes a decimal point. Then display the integer part of the number (the part of the number to the left of the decimal point) and the decimal part of the number (the part of the number to the right of the decimal point, including the decimal point Follow the 3 steps in the Information...

  • CSE/EEE230 Assignment11 Due Date Thursday, April 25th, 5pm Note: the lowest scored assignment wil...

    CSE/EEE230 Assignment11 Due Date Thursday, April 25th, 5pm Note: the lowest scored assignment will be dropped. Important: This is an individual assignment. Please do not collaborate. It must be submitted on-line (Blackboard). No late assignment will be accepted Minimal Submitted Files You are required to turn in the following source file: assignment11.s Objectives: -write assembly language programs to:             -perform arithmetic on floating point numbers             -use syscall operations to display floating point numbers and strings on the console window             -use syscall...

  • Please help me with these, thank you! 3. **25.3 (Implement inorder traversal without using recursion) Implement...

    Please help me with these, thank you! 3. **25.3 (Implement inorder traversal without using recursion) Implement the inorder method in BST using a stack instead of recursion. Write a test program that prompts the user to enter 10 integers, stores them in a BST, and invokes the inorder method to display the elements. 4. **25.4 (Implement preorder traversal without using recursion) Implement the preorder method in BST using a stack instead of recursion. Write a test program that prompts the...

  • This is a matlab HW that I need the code for, if someone could help me figure this out it would b...

    This is a matlab HW that I need the code for, if someone could help me figure this out it would be appreciated. The value of t can be estimated from the following equation: in your script file, estimate the value of π for any number of terms. You must ask the user for the desired number of terms and calculate the absolute error/difference between your calculation and the built-in MATLAB value ofpi. Display your results with the following message...

  • CSE/EEE230 Assignment11 Due Date Thursday, April 25th, 5pm Note: the lowest scored assignment will be dropped....

    CSE/EEE230 Assignment11 Due Date Thursday, April 25th, 5pm Note: the lowest scored assignment will be dropped. Important: This is an individual assignment. Please do not collaborate. It must be submitted on-line (Blackboard). No late assignment will be accepted Minimal Submitted Files You are required to turn in the following source file: assignment11.s Objectives: -write assembly language programs to:             -perform arithmetic on floating point numbers             -use syscall operations to display floating point numbers and strings on the console window...

  • C programming language Purpose The purpose of this assignment is to help you to practice working...

    C programming language Purpose The purpose of this assignment is to help you to practice working with functions, arrays, and design simple algorithms Learning Outcomes ● Develop skills with multidimensional arrays ● Learn how to traverse multidimensional arrays ● Passing arrays to functions ● Develop algorithm design skills (e.g. recursion) Problem Overview Problem Overview Tic-Tac-Toe (also known as noughts and crosses or Xs and Os) is a paper-and-pencil game for two players, X and O, who take turns marking the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT