### spheres volume calculator help

Hi everyone, I'm currently in the process of making a program that prompts the user for two radius of two separate spheres then it calculates the sum of the two radius's. Then it takes the final sum and calculates the volume of a sphere from that sum ((4/3)pie(r)^3). I'm having trouble getting the correct calculations just using int main(). So i've been trying to use the void function to help me out but I am getting errors. I will post what I have so far and if anyone can help me in the right direction it will be much appreciated.

Thank you.

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344`` ``````#include #include using namespace std; void sum (double, double); int main() { double r1,r2; cout<<"Enter in two radii: "; cin >>r1>>r2; sum(r1,r2); volume; system("PAUSE"); return EXIT_SUCCESS; } void sum(double r1, double r2) { double total; total = r1 + r2; cout<
Hi there,

What kind of errors are you getting? Compilation errors or runtime errors? Also, could you please copy the errors you are getting into your post?

Thanks,
NwN
1) you are not calling your volume function
2) Why do you have 3 arguments here?
Do not use argument list to declare additional variables to use.
3) 4/3 = 1.

do something like:

 ``1234567`` ``````void volume(double radius) { const double coeff = 4.0/3.0; //sic! double vol = coeff * M_PI * radius * radius* radius; std::cout << vol; }``````
Last edited on
MiiNiPaa, you are right I had too many arguments. Looking at the code you wrote made it much more simple. I was trying to complicate things by parting out the equation. I forgot to make it 4.0/3.0 instead of 4/3.

Thanks a lot for your help.
Topic archived. No new replies allowed.