characteristics of array

Characteristics of array :


  1. The declaration int a [5] is nothing but creation of 5 variables of integer types in the memory. Instead of declaring five variables for five values,the programmer can define them in an array.
  2. All the elements of an array share the same name,and they are distinguished from one another with the help of an element number.
  3. The element number in an array plays major role for calling each element.
  4. Any particular element of an array can be modified separately without disturbing other elements. 
                       int a [5]={1,2,3,4,8}; 


         If the programmer need to replace 8 with 10,he/she needs to require to change other numbers              except 8.To carry out this task the statement a [4]=10 can be used.Here other three elements are          not disturbed.
     5. Any element of an array a [ ] can be assigned/equated to another ordinary variable or array                    variable of its type.


For example :

       b= a [2];
       a[2] =a [3];
 a)    In the statement b=a [2]  or vice versa, value of a[2] is assigned to "b", Where 'b' is an integer.
 b)    In the statement a [2] = a [3] or vice versa,value of a [2] is assigned to a [3],Where the both the           elements are of the same array.
 c)    The array elements are stored in continuous memory location.The amount of storage required             for holding elements of the array depends on its type and size.The total size in bytes for a single         dimensional array is computed as shown below.
        Total bytes   sizeof (data type ) x size of array