An array element is one of the values within an array and is accessed by its position within the array.
An array is a structure that holds multiple values of the same type. The length of an array is established when the array is created (at runtime). After creation, an array is a fixed-length structure. We can define an array as a data structure containing a fixed number of contiguous storage elements all of the same type.
Questions:
1.- How can we create an array?
You use a new operator, plus the data type of the array elements, plus the number of elements desired enclosed within square brackets. The next statement in the sample program allocates an array with enough memory for ten integer elements and assigns the array to the variable an Array declared earlier.
2.- How can we access in an array?
The memory has been allocated for the array, the program assign values to the array elements. The code shows the reference an array element, either to assign a value to it, or to access the value, and the square brackets to the array name. The value between the square brackets indicates the index of the element to access.
3.- How can we know the size of an array?
To get the size of an array, you write arrayname.lenght in the program
4.- How we declare an array in the code? Answer: e
a) int [] an array;
b) like variable
c) array type
d) array name
e) all the above
5.- How many bytes needs a contiguously in an array? Answer: a
a)2 bytes
b)4 bytes
c)8 bits
d)32 bits
References:
pweb.netcom.com/~tjensen/ptr/pointers.htm
Textbook on the webpage of
www.pkirs.utep.edu/cis3355