Question: 1. Write a C program with the following functions: volume: write a function named volume with two args: doubles giving the radius and height of
1. Write a C program with the following functions: volume: write a function named volume with two args: doubles giving the radius and height of the cone. volume may assume without checking that both args are positive. volume's job is tocompute and return the volume of a cone with the given radius and height. According to mygeometry book
Volume=1/3(pi*r^2*h)
where R and H are the radius and height of the cone, and is 3.14159265358979323846
volume does no I/O.
die: write a function named die with one arg: a C-string (that is, an array of chars terminated with the null char) that is the error message to output. die does not change the C-string. die's job is tooutput the arg alarmingly and then to terminate the program by calling exit(EXIT_FAILURE) .(exit and EXIT_FAILURE are defined in the
main: write a function named main that will output a prompt (short prompt is fine) try to input the radius and height of a cone.
If the input fails (because the user typed "blah"), c&d: that is, complain and die by calling
your die function.
Both the radius and height are supposed to be positive; if not, c&d call your volume function to get the volume output the volume with explanatory text (short explanatory text is fine)This program only has to deal with one input; there's no looping involved.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
