. .




An array is a group of items that can be identified as similar because they are of the same nature.
Arrays are a vital part of programming, as they allow the programmer to store more than one value in a variable, whilst retaining a single reference. If we think of a variable as a single slot in memory (or a box) that can contain data of a certain type - number, character, etc. - then an array is the equivalent of a box divided into partitions, each containing a piece of data. Of course, because the array box is storing more information than a single variable box, it is much bigger : it needs more memory.
We can use the same name to access the variable, but we need some way to differentiate between the individual slots. To do this we use an index into the array. For example, supposing we have an array that is 100 units wide, we might access the hundredth unit thus:
myArray[99] = 3;
This example also illustrates another feature of most arrays - the index is usually zero based. In other words, the index to the first item is [0] and the index to the last item is [number of elements - 1].
In many programming languages, a string is treated as an array of characters. Usually these arrays are terminated with a null character to indicate the end of the string. This allows software to process strings without knowing the dimension of the array at design time.


Cite this Simulator:

..... .....
Copyright @ 2018 Under the NME ICT initiative of MHRD (Licensing Terms)
 Powered by AmritaVirtual Lab Collaborative Platform [ Ver 00.12. ]