Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
volumeOfCone
#include <iostream>
using namespace std;
double getConeVolume(double, double);
int main()
{
//declare variables
double coneRadius = 0.0;
double coneHeight = 0.0;
double coneVolume = 0.0;
//Prompt the user for inputs
cout << "Enter the radius of the cone: ";
cin >> coneRadius;
cout << "Enter the height of the cone: ";
cin >> coneHeight;
//Do the calculation --- Call the function
coneVolume = getConeVolume (coneRadius, coneHeight);
//Display the result
cout << "The volume of your cone is: " << getConeVolume << endl;
system("pause");
return 0;
} //end of main
// function definition
double getConeVolume(double coneRadius, double coneHeight)
{
const double PI = 3.1415;
return .3333 * PI * coneRadius * coneRadius * coneHeight;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment