I'm trying to get this program to work but something is wrong, don't know what exactly. The formula - if you're wondering - for the volume of a sphere is 4/3 * 3.1416 * radius(cubed)
are my functions wrong? it says num2 isn't initialized to something. help.
well um you never actually called your sphere volume function after getting the radius then you tried to output the volume. try putting your function on line 17 right now if you output num2 you're probably getting something like 644123123
That's beause you try to cout the value of num2 while it is "dirty"(not initialized/set to anything). You must give it a value before trying to cout it.
num2 = sphereVol(radius); not sure what the 'R' is there for
THat is how you set a variable equal to the return of a function with a paramater of something
You should remove the radius parameter from SetSphere function, since it is not being used, and do this: r=SphereVol(radius);
in the main function, just before cout-ing r.
{ float r, radius;
cout << "Enter a radius: ";
cin >> radius;
r = SphereVol(radius); //put it here!!!
cout << "Volume of a sphere with a radius " << radius << " is " << r; // Do (3) - print output and call SphereVol() }
You should put it after cin in a value to radius, as I've done above.
nass before any of us CAN help you need to read those two pages I linked you. That is a pretty basic thing and I already told you how a couple of times.
You are not calling the functions you need to call them by something like function(parameter);