R
rafa
Hi I'm just learning C and I was trying to do an exercise in a book
which asks me to write a program to calculate the volume of a
sphere. I know the formula is Volume = (4/3)*(Pi)*(Radius)^3
and I've been trying to write that but have been unsuccesfull so far.
I tryed:
volume = 4/3 * PI * radius;
volume = volume * volume * volume;
or
volume = (4/3 * (PI * radius)) * (4/3 * (PI * radius)) * (4/3 * (PI *
radius));
And a few other variations on the algorithm. The rest of program works
fine I just don't know the proper syntax for creating this algorithm.
If someone would be kind enough to answer my question I'd also
appreciate if they could explain why the syntax needs to be the way it
is. Since right now I'm quite confused.
-rafa
which asks me to write a program to calculate the volume of a
sphere. I know the formula is Volume = (4/3)*(Pi)*(Radius)^3
and I've been trying to write that but have been unsuccesfull so far.
I tryed:
volume = 4/3 * PI * radius;
volume = volume * volume * volume;
or
volume = (4/3 * (PI * radius)) * (4/3 * (PI * radius)) * (4/3 * (PI *
radius));
And a few other variations on the algorithm. The rest of program works
fine I just don't know the proper syntax for creating this algorithm.
If someone would be kind enough to answer my question I'd also
appreciate if they could explain why the syntax needs to be the way it
is. Since right now I'm quite confused.
-rafa