Loops 2
Arrays and loops
-
Make an array of ten random integers, each one -10<=n<=10. Print it out.
-
Make an array that contains multiples of 10, starting from 0 and ending at 130. Print it out.
-
Ask the person for an integer n. Make an array containing the first n multiples of 5.
How many multiples? 20 [0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95]
-
Extend your previous program. Have the computer pick a random integer between 1 and 10. Extend the array by adding in that many more multiples of 5.
How many multiples? 20 [0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95] 8 more multiples [0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135]