Answer to Question #273839 in C++ for sonu

Question #273839

 Write function to ‘power’ which


-calculates square of a number when one argument is provided.


-calculates x raised to power y when two arguments are provided.


-calculates x raised to power y, raised to power z, when three arguments are provided.


1
Expert's answer
2021-12-03T14:33:55-0500
#include <cmath>

double power(double n) {
 return n*n;
}
double power(double n, double x) {
 return pow(n, x);
}
double power(double n, double x, double y) {
 return pow(n, pow(x, y));
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS