Tutorials

Arrays


Arrays basic


An array is static data structure used to store data of homogeneous (same) type.

Homogeneous simply says that an array can be used to store only integer values or only float values or only characters, or String, etc.

Static nature means array size is defined at the beginning and it cannot grow or shrink at later stage. 

 

Important points on Arrays

  • Array is static in nature. Its size is defined at the beginning and cannot increase or decrease based on the requirement.
  • All the elements in array are stored in consecutive or contiguous memory location.
  • Data type of an array is declared only at the beginning during initialization. So an array can either be declared as int, float, char, etc.
  • An array can hold multiple values of same type under single reference name, which is name of the array.
  • An array is index based data structure. 
  • Each element in array is stored at a particular index and could accessed using the index easily.
  • Array can be used to create complex data structures such as stack and queues.

The data or item that we store in array is known as element.

Each element in array is of particular data type.

Each element is stored at particular index from which it can be easily accessed.

Given below is diagrammatic representation of array.

 

array by tutorialsinhand.com

 

Points to note:

  • Array index starts from 0
  • First element 3 is stored at index 0, second element 34 at index 1 and so on.
  • Above array is of length 10 and thus is capable of storing maximum 10 element.
  • We can retreive elements from any position using index from the above array.
  • We can delete, search and insert the element in array.

Types of Arrays

We have two types of arrays available:

  1. Single dimensional
  2. Multi dimensional

We will study about array initialization, declaration and operations in upcoming chapters.



Please Share this page
Views : 27