Define a function pyramid volume with double parameters baselength, basewidth, and pyramid height, that returns as a double the volume of a pyramid with a rectangular base. relevant geometry equations: volume = base area x height x 1/3 base area = base length x base width. (watch out for integer division).

Respuesta :

W0lf93
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; }