Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a library (i.e. a .h header and .c source file) that calculates volume of

ID: 3781547 • Letter: C

Question

Create a library (i.e. a .h header and .c source file) that calculates volume of three geometric shapes: the sphere, the right (untilted) cylinder, and the ellipsoid (look it up!). The user supplies the appropriate parameter such as radius for the sphere in decimal form when calling the function. Your function returns the volume.

All the formulas use p; use a #define statement in the source code to replace _PI_   with 3.14159. Underscores in defined names are used to avoid unwanted substitutions; you wouldn’t want PIE to become 3.14159E for example.

Make sure you name the functions and variables to enhance readability. Add comments for clarity.

If you have main() or printf() in your source code you are not doing what I am asking.

*This is programing in C and don't answer the question same as before

Explanation / Answer

//volume.h

#define _PI_ 3.14159

// returns volume of a sphere of a given radius
double volume_of_sphere(double radius);

// return volume of a cylinder of a given radius and height
double volume_of_cylinder(double radius, double height);

// return volume of a ellipsoid of a given a,b,c value
double volume_of_ellipsoid(double a, double b, double c);

//-----------------------------------------------------------------------------------------

//volume.c

#include "volume.h"

double volume_of_sphere(double radius)
{
return _PI_*radius*radius*radius;
}
double volume_of_cylinder(double radius, double height)
{
return _PI_*radius*radius*height;
}
double volume_of_ellipsoid(double a, double b, double c)
{
return (4*_PI_*a*b*c)/3;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote