Answer / Explanation:
To answer this question, we first define the parameters which are,
Volume: This can be defined or refereed to the quantity of three-dimensional space enclosed by a closed surface. For the purpose of illustration, we can say that the space that a substance or shape occupies or contains. The SI used in measuring volume is mostly in cubic metre.
Therefore,
Volume, where Volume = base area x height x 1/3
where,
Base area = base length x base width
However, we also watch out for the division integer.
So moving forward to write the code solving the question, we have:
double Pyramid Volume (double baseLength, double baseWidth, double pyramid Height)
{
double baseArea = baseLength * baseWidth;
double vol = ((baseArea * pyramidHeight) * 1/3);
return vol;
}
int main() {
cout << "Volume for 1.0, 1.0, 1.0 is: " << PyramidVolume(1.0, 1.0, 1.0) <<
endl;
return 0;
}