Answer:
The problem demands a function PyramidVolume() in C language since printf() command exists in C language. Complete code, output and explanation is provided below.
Code in C Language:
#include <stdio.h>
double PyramidVolume(double baseLength, double baseWidth, double pyramidHeight)
{
return baseLength*baseWidth*pyramidHeight/3;
}
int main()
{
printf("Volume for 1.0, 1.0, 1.0 is: %.2f\n",PyramidVolume(1, 1, 1));
printf("Volume for 2.5, 5, 2.0 is: %.2f\n",PyramidVolume(2.5, 5, 2.0));
return 0;
}
Output:
Please also refer to the attached output results
Volume for 1.0, 1.0, 1.0 is: 0.33
Volume for 2.5, 5, 2.0 is: 8.33
Explanation:
A function PyramidVolume of type double is created which takes three inputs arguments of type double length, width and height and returns the volume of the pyramid as per the formula given in the question.
Then in the main function we called the PyramidVolume() function with inputs 1.0, 1.0, 1.0 and it returned correct output.
We again tested it with different inputs and again it returned correct output.