I'm having a little trouble with this block of code:
Code:
int sphere()
{
float radius_2, volume;
printf( "Radius: " );
scanf( "%f", &radius_2 );
volume = ( 4 / 3 ) * PI * pow( radius_2, 3 );
printf( "Volume = %f\n", volume );
volume_menu();
return 0;
}
PI is defined at the beginning of the program as 3.14159 using:
My problem is that this function is returning 25.132721 as as volume instead of the correct value of ~33.49. I've narrowed the problem down to the 'volume = ( 4 / 3 ) * PI * pow( radius_2, 3 );' statement; specifically the '( 4 / 3 )' portion of the statement. It seems to me that it is returning 1.0 as 4 / 3 instead of the actual value - even though volume is declared type float.
Thanks for any help!