Project 4 There are four parts to this project 1. Create a programcalled part1.c
ID: 3618448 • Letter: P
Question
Project 4
There are four parts to this project
1. Create a programcalled part1.cpp containing a recursivefunction that accepts two double arguments (double x, double y) asparameters and returns the result of x raised to the y power. Themain function should call this function to demonstrate yourrecursive function.
2. Create a programcalled part2.cpp containing a recursivefunction that accepts an array of integers and a number indicatingthe number of elements as arguments. The function shouldrecursively calculate the sum of all the numbers in the array. Themain function calls this function to demonstrate that if workscorrectly.
3. Create a programcalled part3.cpp containing a recursiveBoolean function called isMember thataccepts three arguments - an array of integers, the size of thearray, and an int value. This function searches array for value. Ifvalue is found, the function returns true. Otherwise, it returnsfalse. Demonstrate the function by calling it with appropriatearguments from the main function.
4. Create a programcalled part4.cpp containing a recursivefunction that accepts a pointer to a null-terminated string as itsargument, and prints the string in reverse order.
Demonstrate the function by calling it from the main function witha string that has been provided by the user. In other words, youwill prompt the user to enter a string and the program will displythe string backward.
All four files must include boththe printHeading function (called frommain) and documentation in the form of comment block at the top ofthe file.
Explanation / Answer
1. /*Create a program called part1.cpp containing a recursive functionthat accepts two double arguments (double x, double y) asparameters and returns the result of x raised to the y power. The mainfunction should call this function to demonstrate your recursivefunction. */ #include double power(double x, double y) { if(y==0) return 0.0; else if(y==1) return x; else return x*power(x,y-1); } void printHeading() { coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.