| array worksheet #2 | Name - |
| Day of Week - |
For all exercises, you can assume that numbers was already declared to be an array of int's with a length of 5. You can also assume that there is a global constant named LENGTH that is equal to the value 5.
1. Write a code segment that uses a for loop to find the sum of all the numbers stored in the array named numbers. The, display that sum outside of the loop.
2. Write a code segment that uses a for loop to display the numbers stored in the array named numbers that are greater than 20. The numbers should be displayed on one line of output rather than separate lines.
3. Write a code segment that uses a for loop to display the numbers in the array named numbers which are odd. The numbers should be displayed on one line of output rather than separate lines.
4. Write a code segment that uses a for loop to display the sum of the odd numbers as well as the sum of the even numbers that are stored in the array named numbers. These two sums should be displayed outside of the loop.
5. Write a code segment that uses a for loop to replace every negative number in the array named numbers with its positive value until the value 0 is found in the array. For example, if -3 is a value stored in index position 2 of the array, then index position 2 should have the number 3 stored there after this loop executes.
6. Assume that idNumbers is an array of integers with the same length as the array named numbers. idNumbers is a "parallel" array to numbers in such a way that the number stored in a given index position of idNumbers is the student ID number of a student whose exam score is stored in the same index position of numbers. Write a code segment that first allows the user to input an integer. The code segment should uses a for loop to find that number in numbers and then display the corresponding ID number that is stored in the same index position of the parallel array idNumbers. If the inputted integer number is not found in numbers, you must display "ID number not found" exactly one time.