Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

When asked to create a program to find the volume of any cone, given its radius

ID: 3778709 • Letter: W

Question

When asked to create a program to find the volume of any cone, given its radius and height, a programmer created this program to implement the formula V=1/3 r^2 h. Compute the following to correct the program: a. Provide the correct parameters for the ComputeVolume function b. Write the call for the function in int main c. Define the ComputeVolume function d. Initialize any other necessary variables

#include using namespace std;

void ComputeVolume ( ); //parameters

int main() { double radius, height, answer; cout << "Input the radius and height of the cone." << endl; cin >> radius >> height; cout<<" Radius : "<< radius; cout<< " Height : " << height; // Call the function cout<< " Volume :"< < answer; return 0; } void ComputeVolume ( ){ //parameters //define function return; }

Explanation / Answer

#include <stdio.h>
#define PIE 3.14
float ComputeVolume(float r, float h, float ans, float r2);
int main() {

float radius , height , ans, r2;

printf("Radius: ");

scanf("%g", &radius);

printf("Height: ");

scanf("%g", &height);

ans = ComputeVolume(radius , height , ans, r2);

printf("Volume: %g ", ans);

return 0;

}
float ComputeVolume(float r, float h, float ans, float r2)

{

r2 = r*r;

ans = (1/3)*PIE*r2*h;

return ans;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote