Array Exercise

Name:  ______________________________________________________________________

For each of the following sets of values, write code that creates and fills an array with the values. Define a constant for the size of the array for 1 - 4. Do NOT use magic numbers! Use a loop when appropriate. Use an "initialization list" for 5.

1. 1 2 3 4 5 6 7 8 9 10







2. 0 2 4 6 8 10 12 14 16 18 20







3. 1 4 9 16 25 36 49 64 81 100







4. 0 0 0 0 0 0 0 0







5. 19 65 12 23 34




Exercises from Computing Concepts with Java 2 Essentials by C. Horstmann.