1/3 is an integer division ( with a truncated result ). Use 1.0 / 3 to have a double as result.
Also you don't need all those parentheses ( C++ is not Lisp :^) 1.0 / 3 * pi * pow(r,2) * h would be fine
I have the similar problem with this.
When I will convert a Celcius degree onto Fahrenheit.
Since I only know that the formula is fahrenheit = 9/5 * celcius + 32
so I use that formula.
In this case, celcius is double type.
But it is failed.
So I change the order of writing the code, like this fahrenheit = 9 * celcius/5 + 32
and it works.
The point is we need to confirm the type of operand such that satisfy our need.
I'm sorry about my English.