Raising a number n to a power p is the same as multiplying n by itself p times. Write a function called power() that takes a double value for n and an int value for p, and returns the result as a double value. Use a default argument of 2 for p, so that if this argument is omitted, the number n will be squared. Create a series of overloaded functions with the same name that, in addition to double, also work with types int, long, and float. Write a main() program that exercises these overloaded functions with all argument types.
Answers
Answered by
5
Answer:
Raising a number n to a power p is the same as multiplying n by itself p times. Write a function called power() that takes a double value for n and an int value for p, and returns the result as a double value. Use a default argument of 2 for p, so that if this argument is omitted, the number n will be squared. Create a series of overloaded functions with the same name that, in addition to double, also work with types int, long, and float. Write a main() program that exercises these overloaded functions with all argument types.
Explanation:
Similar questions