iOS Development

Course No. 10-152-139

Assignment 7-1

  • Create a new Xcode project. Name it Assignment-7-1.
  • Add #include math.h to the main.c file right under #include <stdio.h>.
  • Access the Wikipedia page for a sphere. You’ll need it for your program’s formulas.
  • Program steps and features.
    • The program will have four (4) functions. The main function counts as one and there will be 3 more.
    • Create a function that calculates and returns the surface area of a sphere. It will have one parameter that is the radius of a sphere.
      • The function must use the constant for pi, and the function that raises a value to the power of another value, from the math.h library.
    • Create a function that calculates and returns the volume of a sphere. It will have one parameter that is the radius of a sphere.
      • The function must use the constant for pi, and the function that raises a value to the power of another value, from the math.h library.
    • Create a function that uses printf statements and outputs the following. It will have one parameter that is the radius of a sphere.
    • The formatting of the output must be:
      • The radius will display one decimal place.
      • The surface area will display 16 decimal places.
      • The volume will display 16 decimal places.
    • In the main function call the previous function at least three times with different arguments that are the radius of spheres. Make sure that one of the values is something like 4.5.
    • The final output will look something this, depending on the values you use:
  • Program verification Don’t skip this part, it’s worth points.
    • In a comment below your program you must write in detail how you verified that your program is giving you the correct output. It is not enough to just say you used a calculator. You must list and describe the steps you took and list the inputs and outputs that you used. Here are some ways that you could verify the results:
      • Use a scientific calculator.
      • Use a spreadsheet.
      • Use an online calculator. List the link if you do this.

IMPORTANT NOTE!!!

All values in the previous examples are incorrect. They were just typed and are not the result of a running program. Do not use them to confirm the accuracy of your program.