The function power(base, exponent) returns the value of ...
The function power(base, exponent) returns the value of baseexponent. For example, power(3, 4) = 3 * 3 * 3 * 3. Assume that exponent is a positive non-zero integer, and base is an integer.
a) Write the function power(base, exponent) using iteration.
b) Write the function power(base, exponent) using recursion. Hint: The recursion step would use the relationship baseexponent = base * baseexponent - 1 and the terminating condition occurs when exponent is equal to 1 because base1 = base.
Sample Solution
a) Iterative Solution
int power(base, exponent)
{
int i, result = 1;
for (i = 0; i ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- the value of education essay
- the value of reading
- the value of reading literature
- what is the value of philosophy
- the value of higher education
- the value of philosophy notes
- the value of philosophy summary
- compute the value of the correlation coefficient
- find the value of the interquartile range
- calculate the value of the sample variance
- find the value of the variable calculator
- calculate the value of the determinant