Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

G++ Programming Goals: Analyzing recursive functions and practicing writing functions Create a new project in Visual Studio. Analyze the code (below) to determine what series

G++ Programming

Goals: Analyzing recursive functions and practicing writing functions

Create a new project in Visual Studio. Analyze the code (below) to determine what series the recursive function calculates. Modify the introductory comments by putting the series in place of the first ______________ plus add some test data and the expected result for the second ______________

Modify main by adding an output statement that tells the user what series is being calculated.

Modify the comments for the recursive function by adding what series is calculated

Write comments for a second function that will perform the same calculation using repetition. Write the code for the second function that will perform the same calculation using repetition (do not use any built-in functions) after the recursive function. Add the function declaration (prototype) for your new function before main. Add a function call to your new function in main. Add and output statement in main to output the result of the call to your new function.

Program:

The program will calculate the series ____________________________________ using a recursive function and a function that uses repetition. input: a floating point value and and integer value output: the result of the series processing: Prompt the user to enter the floating point value and the integer value. Call the function that uses recursion and output the result in main. Call the function that uses repetition and output the result in main. test data: _________________________________ */ # include using namespace std; double RecursiveFunct(double c, int i); //put function declaration (prototype) for your function here int main() {

double abc, resulta, resultb; int def; //output what series will be calculated cout << "Enter a floating point number "; cin >> abc; cout << "Enter a whole number greater than or equal to zero. "; cin >> def; while (def < 0) {

cout << "The whole number MUST be greater than or equal to zero

zero! ";

cout << "Enter a whole number greater than zero. "; cin >> def;

} resulta = RecursiveFunct(abc, def); cout << "The result of the series calculated using recursion is "

<< resulta << ". ";

// add function call to repetitious function here store the returned value

in resultb

//add output statement to state the result of the function using

repetition return 0; } /* Recursive funtion to calculate the series _______________________________________ input: a floating point number and a whole number is passed to the function. The whole number has been confirmed to greater than or equal to zero output: result of the series processing: use recursion to call the function again as long as the whole number is greater than 1

*/ double RecursiveFunct(double x, int n) {

double ans; if (n == 0) { ans = 1; } else {

ans = 1 + x * RecursiveFunct(x, n - 1);

} return ans;

} //put comments for your function that uses repetition here and your function definition

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Familiarity with transmission substation equipment desirable

Answered: 1 week ago