Problem

Modify your pow method from Exercise 5 to make a new method called pow2 that uses the type...

Modify your pow method from Exercise 5 to make a new method called pow2 that uses the type double for the first parameter and that works correctly for negative numbers. For example, the call pow2 (−4.0, 3) should return −4.0 * −4.0 * −4.0, or −64.0, and the call pow2 (4.0, −2) should return 1 / 16, or 0.0625.

Exercise

Write a method called pow that accepts a base and an exponent as parameters and returns the base raised to the given power. For example, the call pow(3, 4) should return 3 * 3 * 3 * 3, or 81. Assume that the base and exponent are nonnegative.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 4
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT