Problem 140

Basic Arrays 2

Create an array that can hold ten integers. Fill up each slot of the array with a random number from 1 to 100. Then display the contents of the array on the screen. You must use a loop.

And, like last time, you must use the .length field of your array and not a literal number (like 10) in the condition of the loop.

Slot 0 contains a 45
Slot 1 contains a 87
Slot 2 contains a 39
Slot 3 contains a 32
Slot 4 contains a 93
Slot 5 contains a 86
Slot 6 contains a 12
Slot 7 contains a 44
Slot 8 contains a 75
Slot 9 contains a 50

◄ 139: Basic Arrays 1 141: Basic Arrays 3 ►



Adapted from ProgrammingByDoing.com
©2013 Graham Mitchell

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.