# Thread: Help with solving Order of Ops Question

1. ## Help with solving Order of Ops Question

I'm stuck on a question in my assignment that's asking me to create a program to calculate the Area-cubed of a cylinder knowing that
Pi = 3.14159 and Radius = 2.2
the formula is 4/3 Pi R^3
and this is the code I have written down:

Code:
```#include<stdio.h.>
#include<math.h>
main()
{
float Pi = 3.14159, num1 = pow(2.2,3), area;
area = 4 / 3 * num1;
printf("%f", area);
getch();
}```
I'm getting different answers if I instead make the 4 / 3 into 1.25, so I was wondering how do I signify the operations in the order it should be in, if it should be according to PEMDAS(which i believe it should be)?

2. Be wary of integer division here, e.g., change 4 / 3 to 4.0 / 3.0

3. Originally Posted by laserlight
Be wary of integer division here, e.g., change 4 / 3 to 4.0 / 3.0
I changed the ints to floating point values and I'm getting a number like 14.121337 where it should be somewhere closer to 33-34

4. Oh, but of course, mathematically, 4/3 is not equal to 1.25.

Plus, I note that you computed 2.2 to the power of 3, but did not multiply by pi.

5. Originally Posted by laserlight
Oh, but of course, mathematically, 4/3 is not equal to 1.25.

Plus, I note that you computed 2.2 to the power of 3, but did not multiply by pi.
Of course it doesn't! haha thanks for the help.

6. Looks more like the formula of volume of sphere. If you are working with a cylinder where's the height parameter?