title: Cone Volume Calculator program
body: <p>I'm working on below program and I want the program to do the same thing, but with not one main() function, but instead one main() function PLUS one user defined function called computeConeVolume that contains the calculation. In other words I want to remove the one line calculation and replace it with a function call, then write and add the function below main with the calculation, surrounded any other syntax that I need to complete it.</p>
  
  <p>The function should contain local variables and a constant declared and must have the calculation, it may not do anything else such as input or output.
  Should be able to declare "global" variables anywhere but no variables above or outside of main() and the function are allowed.
  A value-returning function should be used because it's a little simpler to understand, but you can employ a void function.
  Need to have a function prototype at the top of the code, then main, then your function.</p>
  
  <p>Need some help with this since I'm new to C++ and trying to learn.</p>
  
  <pre><code>//Cone Volume Calculator Program
  
  #include &lt;iostream&gt;
  using namespace std;
  
  int main( )
  {
      //Declare variables and constants
      double coneRadius = 0.0;
      double coneHeight = 0.0;
      const double PI = 3.1415;
      double coneVolume = 0.0;
  
      //Prompt the user for inputs
      cout &lt;&lt; "Enter the radius of the cone: ";
      cin &gt;&gt; coneRadius;
      cout &lt;&lt; "Enter the height of the cone: ";
      cin &gt;&gt; coneHeight;
  
      //Do the calculation
      coneVolume = 0.3333 * PI * coneRadius * coneRadius * coneHeight;
  
      //Display the result
      cout &lt;&lt; "The volume of your cone is: " &lt;&lt; coneVolume &lt;&lt; endl;
  
      system("pause");
      return 0;
  } //end of main
  </code></pre>