If need to calculate the area of circle the function looks
double Hero1(double r)
{
const double PI=3.141592653589323846;
return PI*r*r;
}
If need to calculate the area of triangle using formula heron’s the function looks
double Hero2(double a, double b, double c)
{
double s=(a+b+c)/2;
return sqrt(s*(s-a)*(s-b)*(s-c));
}
Comments
Leave a comment