Declaring the volume function
double PyramidVolume(double baseLength, double baseWidth, double pyramidHeight){
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;
}
Defining the function,
include <iostream>
double PyramidVolume(double, double, double);
int main()
{
std::cout << "Volume for 1.0, 1.0, 1.0 is: " << PyramidVolume(1.0, 1.0, 1.0) << std::endl;
return 0;
}
double PyramidVolume(double length, double width, double height)
{
return length * width * height / 3;
}