Question: C++ Code Help: Wont Compile - Most likelty function prototype #include #include #include using namespace std; const double pi = 3.14; void calculate (double, double,
C++ Code Help: Wont Compile - Most likelty function prototype
#include
#include
#include
using namespace std;
const double pi = 3.14;
void calculate (double, double, double, double); //Function Prototype
int main()
{
double r;
double h;
double surfacearea = 0;
double volume = 0;
cout << "Please enter the radius of the cone" << endl;
cin >> r;
while (r < 0)
{
cout << "You entered a radius of " << r << endl;
cout << "Please enter a positive value for the radius" << endl;
cin >> r;
}
cout << "Please enter the height of the cone" << endl;
cin >> h;
while (h < 0)
{
cout << "You entered a height of " << h << endl;
cout << "Please enter a positive value for the height" << endl;
cin >> h;
}
calculate(r, h, &surfacearea, &volume);
cout << "A cone with radius of " << r << " and a height of " << h << endl;
cout << "has a volume of " << volume << endl;
cout << " and a surface are of " << surfacearea << endl;
system("pause");
return 0;
}
void calculate(double radius, double height, double surfacearea, double volume)
{
surfacearea = pi * radius * (radius + sqrt(radius * radius + height * height));
volume = (1.0 / 3) * pi * radius * radius * height;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
