1.

Raising a number n to a power p is the same as multiplying n by itself p times. Write as overloaded function power() having two versions for it. The first version takes double n and int p and returns a double value. Another version takes int n and int p returning int value. Use a default value of 2 for p in case p is omitted in the function call.

Answer»

double power(double n,int p=2)

{

double res=pow(n,p);

return res;

}

int power(int n,int p=2)

{

int res=pow(n,p);

return res;

}



Discussion

No Comment Found

Related InterviewSolutions