Write a C program consisting on 5 files 1 A source code file
Write a C program consisting on 5 files.
1. A source code file containing the definitions of all functions other than main.
2. A header file containing the prototypes for all functions defined in file 1 above along with the definition of any constants specified. Note that you may add additional constants as you deem helpful.
3. A source code file containing the definition of your main function.
4. A Makefile that you used to build your program. Your Makefile can be based on either the basic or the advanced Makefiles shown in class.
5. A plain text file (not an MS Word or other document type) containing the output from running the program with the indicated inputs. The output should include everything that occurred at the command line after you began executing the program until the program exits.
Write a C program that calculates and outputs the volume and surface area of a sphere. Your program should consist of the following:
 1. Define a constant for  with a value of 3.1415926 using a preprocessor directive. All functions should make use of this constant for .
 2. Write a function that takes as an argument the radius of a sphere and calculates and returns the volume of a sphere with that radius. The volume v of a sphere is given by:
 v = 4 / 3 *  * r3
 3. Write a function that takes as an argument the radius of a sphere and calculates and returns the surface area of a sphere with that radius. The surface area s of a sphere is given by:
 s = 4 *  * r2
 4. Write a function that takes no arguments and gets and returns a positive radius value input by the user. Give the user as many chances as necessary to enter a valid positive number.
 page of 1 3
 5. Write a main function that does the following in the indicated order, using the functions you defined above as appropriate:
 a. Get a positive radius value from the user.
 b. Calculate the volume of the sphere.
 c. Calculate the surface area of the sphere.
 d. Output the radius, volume, and surface area in a sentence with 4 digits to the right of the decimal place for all values.
Solution
Code:
#include <stdio.h>
 #include <math.h>
 #define PI 3.1415926
 double volumeOfSphere(int r);
 double surfaceAreaOfSphere(int r);
 int inputRadius();
 int main(){
    int r;
    r=inputRadius();
    printf(\"Radius is :%d\ \",r);
    printf(\"%.4f\",volumeOfSphere(r));  
    printf(\"\ \");
    printf(\"%.4f\",surfaceAreaOfSphere(r));  
    return 0;
 }
double volumeOfSphere(int radius){
    return (4.0/3) * PI * radius * radius * radius;
 }
 double surfaceAreaOfSphere(int r){
    return 4*PI*r*r;
 }
 int inputRadius(){
    int r;
    printf(\"Please enter the radius:\");
    scanf(\"%d\",&r);
    return r;
 }
Output:


