There are two types of arrays: Static and Dynamic
Arrays can be categorized into two different types: Static and Dynamic. The difference comes from how and where memory are stored.
For the static array, memories are allocated in the stack at compile time.
int arr[5] = {0, 1, 2, 3, 4};
On the other hand, memories are allocated at the heap in runtime for the dynamic array.
const int SIZE = 5;
int *arr = (int *)malloc(sizeof(int) * SIZE);
for(int i=0; i<SIZE; ++i) {
arr[i] = i;
}
free(arr);
Notice that we have to manually allocate and deallocate memories. Not all languages have a garbage collector.