Hi all newbie here.
I need some help. Can anyone tell me why the following program only gives me a round number for the volume when it is below 1 SQ ft but a decimal when it is above 1 SQ ft? (Ex 25 vs 1.25). This is a school assignment, to write a function and pass the value to main. I know I have made some errors but hey, I've only been coding c++ for a few weeks.
P.S. I have to turn this in tomorrow so any help you can give would be appreciated. Oh and also, please provide explanations that a newbie can understand...lol....
Code starts here:
using namespace std;
int CylVol(double, double);//initialize function
int CylVol(double Length, double Radius)
const double pi = 3.1416;
vol = pi * pow(Radius, 2) * Length;// calculate the volume using
// V = 3.1416 * R^2 * L
cout << endl;//print blank line
cout << "Calculate Cylinder Volume by\n"
<< "entering the Length and Radius.\n"
<< "Dimensions MUST be entered in INCHES." << endl;
cout << endl;
cout << "Enter Length of Cylinder in INCHES: " << endl;
cin >> Length;
cout << "Enter Radius of Cylinder in INCHES: " << endl;
cin >> Radius;
cout << endl;
Volume = CylVol(Length, Radius);//execute function
if (Volume > Multiplier)
Volume = Volume/Multiplier;
cout << "The Volume is " << Volume << " Square Feet" << endl;
cout << "The Volume is of the Cylinder is: " << Volume << " Square Inches" << endl;//print calculated volume to the screen
Awesome thanks! I knew it had to be something easy. I didn't realize that the "type" controlled what kinda info the function returned. Guess I should have. Thanks for the help, you guys will probably get tired of my questions. ;)