CMPSC 201 - Arrays Worksheet #1 Name -

1. (True/False) You must declare an array in order to access individual values within the array.
2. (True/False) An array can be initialized to contain specified values in its declaration statement.
3. (True/False) The statement   int scores[10];   declares an array to have 10 elements with the index positions 1 through 10.
4. (True/False) Each variable in an array is called an index.

5. Write a statement that declares an array of doubles named scores with 10 elements.

 

6. Write a statement that declares an array of integers named temperatures with 5 elements & initializes each element to the value 0.

 

7. Write a statement that declares an array named numbers and initialize its with the values 23, 14, 2, 85, 0, 3 (in this order).

 

8. Write a statement that will set the third element of an array named scores to the value 34.3.

 

9. Write a statement that will displays the value of the eighth element of the array temperatures to the screen.

 

10. Write a program that declares a one-dimensional array of ten integer elements named sums. Using a for loop, assign the value 10 to each element of sums.












11. Write a program that allows the user to enter five integers which are stored into an array named list. Also, use a loop to find and display the sum of the elements in the array.