HW2: Some Array Stuff

NOTE: Each line item in this homework should be its own function, but we won't talk about functions until week 4. So you should start this assignment and do each line item separately in the program as you are working, so that you can easily move them into functions.

  1. Create an Array with 100 numbers in it. Each number should be randomly generated, and somewhere between 100 and 200.
  2. Make a function that tells us the total of the array.
  3. Make a function that returns true if the array's total is prime.
  4. Calculate the average of the array.
  5. Generate a new array (using the same parameters as above) 100 times, and then return the average TOTAL of each array.
  6. Trace out the "word form" of each number in the array. That is, if the first three numbers in the array are 15, 90, and 22, you should trace out "fifteen, ninety, twenty two".
  7. Set each value in the array to it's negative version.
  8. Make a function that takes in an integer (this can be randomly generated, or entered by the user). This function returns true if the array contains the specified int.
  9. Sort the array (by hand, DO NOT USE the built in sort() function). We will discuss a method for doing this in class.
  10. Tell me the median of the array.
  11. Extra credit: Tell me the mode of the array.
Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Twitter
  • Google Bookmarks
  • Fark
  • Google Buzz

Comments are closed.