In main, r and h are defined as integers. cin >> r tries to get an integer and reads 3. cin >> h tries to read another integer but finds . which isn't a digit so the cin fails. Hence h hasn't been changed by the cin. As r and h haven't been previously initialised, h contains whatever happens to be in the memory location used for h. Hence the weid result.

You should check that cin has succeeded after it's used and if it has failed, output an error message. Also r and h should be initialised (usually to 0) when they are defined.

This leads on from my question in post #50 about how are you going to allow the user to input of either int, float or double?