What is array ?

A fundamental data structure consisting of a collection of elements, each element has index value.

int a[5] = {1,2,3,4,5};

Introduction :

  1. Homogeneous

    Stores elements of the same data type.

  2. Contiguous Memory

    Adjacent memory blocks for fast access.

  3. Fixed Size (static)

    In some languages, size is determined at compile-time.

Memory representation :

Address of arrays[I] = base_address + (i * size_of_data_type) 
index 0 index 1 index 2 index 3
[ 1 ] [2] [3] [4]
0x100 0x104 0x108 0x112

Initialization of Array :