Hello! I am writing a program for a class I am taking, but I am stuck. The directions for the assignment are:
Write a program that (using a function and no math libraries) displays the volume of a sphere with a radius from 0 to 4.0 in .2 increments. Use float type for the return type and argument type.
The program runs fine; however, my teacher said it is incorrect because "You did not write a function for any of these programs. The result must take place in a function and be returned to main()" I'm lost.
I submitted the assignment to my teacher, but he returned it saying that I did not write a function. I need to write a function that returns to main. I am lost. What do I need to do?
Also, you should try to make the formula more accurate. 1.33 is only sort of close to 4/3 and 3.14 is only sort of close to pi.
If you #include <math.h> then you may be able to use the constant M_PI. So the formula would become 4.0/3.0*M_PI*r*r*r. Note that it's 4.0/3.0, not 4/3. Since 4 and 3 are integers, 4/3 is 1.