Classwork 12: Array Introduction

Tuesday, August 07, 2012     


[Previous Classwork] [Next Classwork]


Complete the following:

  1. Create the file cw12.c for a classwork assignment and start your file as normal.
  2. You need to use the arrays in this assignment
  3. Your program is going to calculate the average of a set of floating point numbers input by the user
  4. Create an array of 10 double values
  5. Ask the user for how many values they want to input
  6. Ensure the number is less than the maximum size of your array
  7. You will store the numbers in your array as the user is inputting them
  8. After all the numbers have been input, you should calculate and print out the average value, do this by looping over all the values, adding them, and then dividing the total by the number of values.
  9. EXTRA CREDIT: After calculating the average, also calculate and display the standard deviation
  10. The standard deviation is calculated by:
    1. Create an array of elements which are set to: average of values - entered value
    2. Square each of these elements
    3. Add up all of these squared elements
    4. Divide this sum by one-less than the number of elements
    5. Take the square root of this value (use sqrt() from math.h)
  11. Once you are sure the program is done and working well, start a script using script
  12. Once the script is running, show you running the program twice.
  13. Exit from the script, which will save the log typescript
  14. Once you are done, use submit to submit two files, cw12.c and typescript

    linux3[26]% submit cs104 cw12 cw12.c typescript
    

  15. After submitting your files, you can verify your files were submitted by using the submitls command
  16. MAKE SURE YOU LOGOUT AFTER SUBMITTING THE ASSIGNMENT AND BEFORE LEAVING CLASS!