Code not working

so what happens is that 4/3 does not get multiplied to the rest of the equation
so all i get is pi*radius*radius*height. please help!

1
2
3
4
5
    float getvolcylinder(float radius, float height)
    {
    return  (4/3*pi*radius*radius*height);

    };
because 4/3 is an integer division. The result is 1

Change it to e.g. 4.0/3 to get the correct result.
no it didnt work :/.
ok no sorry it worls . Thanks :D
I can't see any reason why coder777's suggestion wouldn't work?

what happens if you temporarily do this:

1
2
3
4
5
6
7

 float getvolcylinder(float radius, float height)
    {
    return  4.0/3;      //*pi*radius*radius*height);

    };


what is returned? It should be 1.3333334
Last edited on
Topic archived. No new replies allowed.