Array

Array is a collection of homogeneous( same data type) data items.

 

There are two types of Array:

1. One dimensional array

2. MULTI DIMENSIONAL ARRAY

1. One dimensional array

Declaration in C :

data_type arr_name [arr_size];

Initialization in C:

data_type arr_name[arr_size]=(value1, value2, value3,….);

Accessing in C:

array_name[index];

2. MULTI DIMENSIONAL ARRAY

Declaration in C :

data_type arr_name [num_of_rows][num_of_column];

Initialization in C:

data_type arr_name[arr_size]=(value1, value2, value3,….);

Accusing in C:

array_name[index];

WHY ARRAYS?

  • Less amount of code
  • Easy access of elements
  • Easy to implement algorithms
  • Random Access

NOTE: We cannot use negative indexes

We can access any elements of array  in O(1) time complexity.

Also read : STACK USING ARRAY IMPLEMENTATION : PUSH AND POP

Leave a Reply

Your email address will not be published. Required fields are marked *