Goals: Analyzing recursive functions and practicing writing functions Create a n
ID: 3803226 • Letter: G
Question
Goals: Analyzing recursive functions and practicing writing functions Create a new project in Visual Studio. Download the file "Labs 4-7MU.cpp" to the folder for your project. Analyze the code 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. Do not use any built-in functions or any concepts beyond Chapter 6 (e.g. arrays) of your textbook. Remember that in addition to the introductory comments for the program, your code should contain comments for each function other than main that states the purpose of the function, input to the function (both input from the function call and interactive input), output from the function (both information sent back to the function call and interactive output), and processing performed in the function. Follow the Assignment Guidelines posted on Canvas.Explanation / Answer
//Function prototpe for repetitious function
double IterativeFunct(double c, int i);
// add function call to repetitious function
resultb = IterativeFunct(abc,def);
//add output statement using repetitious function
cout<<"the result of the serious calculated using repetition is "<<resultb<<" ";
//Function definition
double IterativeFunct(double x, int n){
double ans = 1;
for(int i=1; i<=n; i++)
ans = 1 + x * ans;
return ans;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.