
Patrick B. answered 01/22/21
Math and computer tutor/teacher
using namespace std;
#include <iostream>
#include <math.h>
//answer and radius-squared passed by address for whatever reason
double ComputeVolume(double r, double h, double * ans, double * r2);
int main(int argc, char** argv)
{
double radius,height,ans,r2;
cout << "Please input the radius :>";
cin >> radius;
cout << "Please input the height :>";
cin >> height;
ans = ComputeVolume(radius,height,&ans,&r2);
cout << "Volume :" << ans << endl;
return 0;
}
double ComputeVolume(double r, double h, double * ans, double * r2)
{
*r2 = r*r;
*ans = (1.0f/3) * M_PI * *r2 * h;
return(*ans);
}