Question
In C++ code write a function called Rpower() that takes a single integer parameter that is greater than or equal to 0, and calculates xn
In C++ code write a function called Rpower() that takes a single integer parameter that is greater than or equal to 0, and calculates xn by using the following recursive formula:
x0 = 1
xn = x * xn-1, if n > 0
Rpower() is to be a recursive method. Note that you cannot use cmath or any mathematics include library in your solution to this recursive method.
Calculate values for xn without using the recursive formula (by determining some number x raised to the power of n for any values of x and n you'd like that are greater than 0), then write the source code for Rpower() and test it with the values you calculated to see if it returns the correct values of xn.
Rpower() is a stand alone function. It should be called by your program's main() function. The main() function should be of the int data type, and should be used to pass the value of the parameter needed to Rpower(). The main() function should end after the Rpower() function has completed. Use hardcoded values for a single integer value used in main() that is passed as the parameter to Rpower().
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started