
One-dimensional arrays questions and answers
Q1. What pieces of information have to be provided when declaring an array?
A1. The identifier you will use, the size of the array and what data type it will hold.
Q2. In an array, what is meant by an ‘element’?
A2. One of the positions in an array.
Q3. Using an example, describe how you would read the value from an element into a variable called Score.
A3. Score = Shots[4] gets the data held in the fourth element of the array called Shots.
Q4. Using an example, describe how you would write to an element from the data held in a variable called Score.
A4. A3. Shots[3] = Score This gets the data held in Score and stores it in the third element of the array called Shots.
Q5. How many items of data can you store in a variable?
A5. One.
Q6. How many items of data can you store in an array?
A6. It depends on how big you said you wanted it when you declared the array!
Q7. Do some research. What is meant by the 'bounds' of an array?
A7. The bounds of an array are the upper and lower index of the array.
Q8. Do some research. What is meant by the lower bounds of an array?
A8. This is the first position in an array. The position of the first index in an array is sometimes position 1 but the first position can also start at position 0 - it depends on the programming language you are using.
Q9. Do some research. What is meant by the upper bounds of an array?
A9. This is the last position in an array. The position of the last index in an array is either given by the declared size of the area, or if the array begins at position 0, then the upper bounds is at position (declared size of array - 1).
Q10. What is meant by a 'one-dimensional' array?
A10. A one dimensional array is a single column of data, all of the same data type but referenced using the same name and an element position e.g. SCORE[3], SCORE[14]. Both of these are referencing the same array but just different positions.