Goals: Analyzing recursive functions and practicing writing functions Create a n
ID: 3803904 • 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 GuidelinesExplanation / Answer
double RecursiveFunc(double c, int n);
double RepeatFunc(double x, int n); //repeat function declaration
int main(){
double result_rep; // new variable taken
cout<<"This output is of recursive Function call "<<resulta<<endl;
result_rep=double RepeatFunc(double x, int n); //repat function call
cout<<"This output is from repeated loop function "<<result_rep<<endl; // displaying output using repeat function
return 0;
}
double RepeatFunc(double x, int n){ //repeat function definition
double ans=0;
if(n!=0){
for(int i=n;i>0;i--){
ans=1+x*ans;
}
}
else{
ans=1;
}
return ans;
}
Hello,
Actually, I have only written the required lines and the previous and next line which would help you to locate where will you fit the statement.
Thank you,
Best wishes
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.