When asked to create a program to find the volume of any con

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 pi r^2 h. Compute the following to correct the program: Provide the correct parameters for the Compute Volume function Write the call for the function in into main Define the Compute Volume function Initialize any other necessary variables

Solution

Here goes the required Program for the question

Program:

#include <iostream>

using namespace std;

void ComputeVolume(double &r,double &h,double &a);

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;
   ComputeVolume(radius,height,answer);
    cout<<\" Volume : \"<<answer;
   return 0;
}

void ComputeVolume(double &r,double &h,double &a){
   a=0.33*3.14*r*r*h;
   return;  
}

Explanation:

 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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site