Programs very often deal with multiple data items possessing common characteristics. In such cases, it is often convenient to place the data items into an array, so that the all share a common name. The individual data items can be either integers or floating – point numbers. However, they all must be of the same data type. Array are a collection of items (i.e. ints, floats, chars) which is stored in a contiguous block of memory.
An array works with a collection of values of the same types. For example, it is required to create a collection of five integers. One way to do it would be to declare five integers directly:
int a, b, c, d, e
But if the declaration of thousands of integers is required, it can be declared using an array.
Each array element is referred to by specifying the array name followed by one or more subscripts, with each subscript enclosed in square brackets. Each subscript must be expressed as a nonnegative integer. The individual element of an array a is referred as a[0], a[1], a[2]…….a[n-1] in an n-element array. Figure shows an n-element array and its individual element.
To access the i-th element in an array a we use a [i]. tables in memory can be represented using two-dimensional array. It has two subscript. b[i][j] represent i-th and j-th column of the array b. Higher – dimensional arrays can be formed, by adding additional subscripts in the similar manner (e.g., c[i] [j] [k]).
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc