Write the definition of a function that takes as input the t

Write the definition of a function that takes as input the three numbers. The function returns true if the first number to the power of the second number equals the third number; otherwise, it returns false. (Assume that the three numbers are of type double)

Please use C++ Visual Studio 2013

Solution

Please find the required program along with its output. Please see the comments against each line to understand the step.

#include <math.h>
#include <stdio.h>

bool powerCheck(double a, double b, double c)
{
double z = pow( a, b ); //find the power of a to the power of b
  
if(c == z) //if the above value is equal to the third parameter, then return true and return false
return true;
else
return false;
}


int main()
{
printf(\"%s\", powerCheck(2,3,8) ? \"true\" : \"false\");

}

-----------------------------------

OUTPUT:

true

Write the definition of a function that takes as input the three numbers. The function returns true if the first number to the power of the second number equals

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site