Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the definition of a function powerTo , which receivestwo parameters. The f

ID: 3609163 • Letter: W

Question

Write the definition of a function powerTo , which receivestwo parameters. The first is a double and the second isan int . The function returns a double .

If the second parameter is negative, the function returns 0.Otherwise, it returns the value of the first parameter raised tothe power of the second.


Instructor's notes: You cannot use the pow() function since you areessentially writing a simpler version of the pow() function. Also,don't forget to take into account when the second parameter ispassed the value 0.

Explanation / Answer

//Hope this will help you.. //don't forget to rate it. double powerTo(double a,int n) { double m=1; int i; if(n < 0) return 0; for(i=1;i