Objectives of this assignment : To create function(s) called mylog that calculat
ID: 3553211 • Letter: O
Question
Objectives of this assignment : To create function(s) called mylog that calculate logarithm. This function should be capable of receiving one or two arguments. If only one argument is received, it calculates natural
log (base e), otherwise it assumes the second argument is the base value.
Unlike the log function provided by C++ compiler, your logarithm function
should accept int, float, and double variable types as arguments. (Hint:
Use default argument, and use either function overloading or function
template. Coerce the argument, so that
Explanation / Answer
double mylog(double a)
{
return log(a);
}
double mylog(double a, double b)
{
return (log(a) / log(b));
}
function overloading
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.