Memory Concept in Array

Updated on January 9, 2026
1 min read

Let’s understand the memory concept of arrays step by step, in easy language, with a proper example.

What happens in memory when an array is created?

When you declare an array, the computer:

  • Reserves a block of memory
  • Stores all elements next to each other
  • Does not leave gaps between elements

This is called continuous memory allocation.

Example Array

int num[5] = {2, 8, 7, 6, 0};

Assume:

  • int takes 4 bytes
  • Base address (starting address) = 2000

How Elements Are Stored in Memory

Array ElementIndexValueMemory Address
num[0]022000
num[1]182004
num[2]272008
num[3]362012
num[4]402016

Explanation:

  • First element starts at base address
  • Each next element is stored after 4 bytes
  • Addresses increase regularly

How Address Is Calculated?

The computer uses this formula:

Address of num[i] =
Base Address + (i × size of data type)

Example:

Address of num[3] =
2000 + (3 × 4)
= 2012

Why Arrays Are Fast?

Because memory is continuous:

  • CPU can directly calculate the address
  • No searching is required
  • Any element can be accessed quickly using its index

This is why:

num[3]

is accessed very fast.

Memory Depends on Data Type

Different data types use different memory sizes.

char ch[5];   // 1 byte each
int a[5];     // 4 bytes each
float f[5];   // 4 bytes each

So memory spacing depends on the data type, not the value.

Important Points for Students

  • Array elements are stored in continuous memory
  • Index starts from 0, not from memory address
  • Size of array = number of elements × size of data type
  • Array size is fixed at declaration time

Simple Summary

When an array is created, the system allocates a continuous block of memory. Each element is placed one after another, and the address of any element can be calculated easily using its index. This makes arrays fast and efficient.