Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP WITH EXAM!!

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Create a program that-
Takes the parameters for a cylinder and finds the volume. The parameters can be input from a file or from the keyboard. THe answer is then output into a file on the screen. THe program will run completely from functions with very little code from your int main section.

ANy help would be appreciated beyond belief, my grade depends on this piece of crap!
 

Hope this helps....

#include "stdio.h"
#include "iostream.h"

#define PI 3.141592654


float CalculateCylinderVolume (const float& diametre, const float& height);


void main()
{

// Declare local variables
float diametre;
float height;
float volume;

// Obtain cylinder dimensions
cout << &quot;Enter the diametre of the cylinder: &quot;;
cin >> diametre;

cout << &quot;Enter the height of the cylinder: &quot;;
cin >> height;

// Retrieve volume of cylinder via function
volume = CalculateCylinderVolume (diametre, height);

// Output result
printf(&quot;\nThe volume of the cylinder is %f\n&quot;, volume);
}


// Function to calculate the volume of a cylinder
float CalculateCylinderVolume (const float& diametre, const float& height)
{
return PI * diametre * diametre * height * 0.25;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top