Hi, you haven't provided the programing language in which you need the code, I'll just explain how to do it using Python, and you can apply a similar method for any programming language.
Answer:
1. def pyramid_volume(base_length, base_width, pyramid_height):
2. Â Â volume = base_length*base_width*pyramid_height/3
3. Â Â return(volume)
Explanation step by step:
In the image below you can see the result of calling the function with input 4.5, 2.1, 3.0.