Section4.19Unit 4A - Toggle Code Practice 4a Arrays (4.1-4.6)
For each of the coding problems below, write your own solution. If you get stuck, click the Get Help button for a personalized mixed-up code problem built from your current attempt.
Write a loop that traverses the array arr from 0 to less than the length of the array. In the loop, double each element in the array arr and print out each new value on the same line separated by β, β. The finished code should print β2, 4, 6, 8, 10, β.
Write a for loop that fills an array with elements that count up from 0 to 50 by 5 (0 5 10 15 20 β¦ 50) and prints out each element on a separate line.
Finish the method to return a new array of length 2 containing the middle two elements of a given array of integers of even length (the parameter) β so {1,2,3,4} should return {2,3}.