Calculating the volume of liquid in a horizontal cylinder?

Calculating the volume of a square tank or vertical cylinder is a about the limit of my Math skills. embarrassingly it's been 25 years since i used cos or square root.

Could someone offer some insight on how to translate this equation into C++?

This is referenced via this page: Horizontal Cylindrical Segment -- from Wolfram MathWorld

In case someone is interested in understanding why.. i have an unusual shape domestic heating oil tank and wish to use an HC-SR4 to measure the quantity of oil.

Thanks to all involved in supporting arduino.