Question

Write the prototype of a function called volumeOfC
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Ans)C++ code:

#include <cmath>
#include <iostream>
using namespace std;
double volumeOfCone(double, double);
int main( )
{
//Declare variables and constants
double radiusOfCone = 0.0;
double heightOfCone = 0.0;
//Prompt the user for inputs
cout << "Enter the radius of the cone: ";
cin >> radiusOfCone;
cout << "Enter the height of the cone: ";
cin >> heightOfCone;
cout << "The volume of your cone is: " << volumeOfCone(radiusOfCone, heightOfCone) << endl;//Call the function and Display the result
system("pause");
return 0;
} //end of main

double volumeOfCone(double radiusOfCone, double heightOfCone) //function that calculates and returns the volume of a cone
{
double PI = acos(-1.0); //initializing value of PI
double volume = radiusOfCone * radiusOfCone * heightOfCone * PI / 3.0;//valculating the volume of a cone
return volume;// returning the volume
}

output:

Enter the radius of the cone:5 Enter the height of the cone: 10 The volume of your cone is: 261.799

Add a comment
Know the answer?
Add Answer to:
Write the prototype of a function called volumeOfCone that calculates and returns the volume of a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT