Array Declaration and Memory Layout

int arr[] = {1, 2, 3, 4};
// Memory layout:
// Index:  0  1  2  3
// Value: [1][2][3][4]
// LB = 0 (Lower Bound), UB = 3 (Upper Bound)

Address Calculation Formula :

address_of(arr[i]) = Base(arr) + i * sizeof(element)

Where:

In C++,array do not track how many elements are logically filled.

size = sizeof(arr)/sizeof(arr[i])
//Commonly used formula To find filled elems in a array. 
//But this is only useful for finding total memory blocks present in a array.
//i.e gives the **total capacity**, not the count of meaningful elements.

Why Indexing Starts from Zero

The compiler translates arr[i] to *(Base(arr) + sizeof(element) * i)

Example:

Base address = 104, sizeof(int) = 4, index = 6
Address = 104 + (4 * 6) = 104 + 24 = 128