Here is the problem: Write a program that uses a void-function called FindCylinderVol that has as an argument an integer h, which represents the height of the cylinder, and a float r, representing the radius. This function will read in a radius from the keyboard, and calculate and return the radius and the volume of a right circular cylinder, given the following equation: vol
Vol = PI * radius^2 * height.
Herer is what I came up with :
#include<iostream>
#include<iomanip>
using namespace std;
voidFindcylinderVol(float);
int main()
{
float radius, vol;
int height;
cons double PI = 3.14159;
cout << " Enter in height\n";
cin >> height;
cout << " Enter in radius\n";
cin >> radius;
voidFindCylinderVol(float r)
{
retuen PI * radius * radius * height;
}
My program not compling, can anyone add some input on what I should do or where I went wrong. Thanks.
#include<iostream>
usingnamespace std;
float findCylinderVol(float, float); // can't be void if returning a value / keeping capitalization consistant
int main() {
float radius, vol, height;
cout << " Enter in height\n";
cin >> height;
cout << " Enter in radius\n";
cin >> radius;
vol = findCylinderVol(radius, height);
} // end of main
float findCylinderVol(float r, float h) {
return 3.14159f * r * r * h; // typo / height is out of scope so it must be passed
}