scores[3] never searches for the fourth value. It calculates where that value sits. Take the base address of the row, add the index times the size of one element. One multiplication and one addition land on the value. That calculation is the whole data structure.
An array is one name for a row of boxes holding values of the same type, the boxes standing side by side in memory. The index counts the boxes from the first one. The fixed size, the instant access, and the failure past the end all follow from that row.
What an array is?
A single name covers a fixed number of values of one type, stored in consecutive memory locations. Five test scores need five separate variables without one. With one, the name scores covers all five, and the number after the name picks which one.
Start from what a variable is: one name, one value. An array keeps the one name and multiplies the value. The type stays the same across the row: all slots in an int array hold ints.
Five ints take 20 bytes because an int takes four, and how binary code works decides what the four bytes mean as a number.
The row lives in RAM, beside the variables and the code that reads it.
The index is arithmetic
In my analysis of one run, gcc 13.3.0 laid five ints at addresses 4 bytes apart, and Python 3.12.3 supplied the list numbers.
The five scores sat at 0x7fff4e2214d0, spaced 4 bytes apart. scores[0] sits at the base, scores[1] 4 bytes on, scores[2] 8 bytes on, scores[3] 12 bytes on, scores[4] 16 bytes on. That puts scores[3] at 0x7fff4e2214dc. The address of any element is the base plus the index times the size of one element. The run confirmed it: reading through the pointer, *(scores + 3), returned 40, the same value as scores[3], and the two addresses matched.

That arithmetic is why access costs one calculation whatever the index. The computer never walks the row; it jumps to the computed address in one step. The index is a count of steps, so the first slot is step zero.
The C standard defines the subscript exactly that way: scores[3] means *(scores + 3) (C standard draft N2310). The brackets are a shorthand for the arithmetic, not a separate operation.
In the compiler’s hands, scores[3] becomes that base-plus-offset load, and what assembly language is shows the load itself.
Why do arrays start at 0? Because the index counts steps from the base, and the first element is zero steps away. Starting at 1 would waste the first slot or force a subtraction on all accesses.
The size is fixed at the moment of creation
sizeof(scores) returned 20, and sizeof(scores[0]) returned 4, so the count is 20 divided by 4: five. The array carries no length of its own; the count comes from the size, and the size is set when the array is created.
A C array cannot grow. Appending a sixth score means building a new array with room for six and copying the five values across. Nothing in the language reserves spare room after the row, because the memory past the end already belongs to the next thing on the stack.
Why can’t a C array grow? Because growth would overwrite whatever sits past the end of the row. A list grows by a different route: it allocates a new, larger block elsewhere and copies the pointers across, then frees the old block.
Python shows the contrast in one line. A five-item list takes append(60) and becomes six items long, with scores[5] holding 60. The fixed array has no such call; its length is decided at creation and does not change.
Loops exist to walk rows like this one, and what iteration in programming is explains the loop that does the walking.
One past the end is not an error in C
The compiler warned three times and built the program anyway. Reading small[3], one past the end of a three-element array, returned 10: the value of whatever sat next door in memory. Reading small[-1] returned 33554432, a number no part of the program ever wrote. Both values are what one run’s memory happened to hold. Neither is defined behaviour.
C performs no bounds check because the array carries no length to check against. The read is legal syntax, the address comes from the base-plus-index arithmetic, and the result is whatever bytes sit there.
That silence is the part that surprised me most. The compiler knew the read was out of bounds, printed a warning for it, and still produced a working program. A warning is not a refusal, and the program ran with a stranger’s number in it.
Python refuses that read. scores[5] on a five-item list raises IndexError: list index out of range. The list knows its length, so the check costs one comparison; the C array carries no length, so no check exists to run.
The neighbour whose value leaked into small[3] sits on the stack beside it, and stack vs heap memory maps where that neighbour lives.
Array vs list: one word, two machines
Python calls its growable sequence a list, and C calls its fixed row an array, and the two words hide two different machines. The table puts them side by side, with the typed array as the middle case.
| C array | Python list | array.array(‘i’) | |
|---|---|---|---|
| What sits in the row | Values themselves | Pointers to objects | Values themselves |
| Space between neighbours | 4 bytes | 8 bytes (pointers) | 4 bytes |
| Element type | One type, fixed | Any type, mixed | One type, fixed |
| Size | Fixed at creation | Grows with append | Grows with append |
| Past the end | Reads the neighbour | IndexError | IndexError |
| Access | One calculation | Calculation plus one lookup | One calculation |

Those gaps are the point. The C values sit 4 bytes apart. The list’s pointers sit 8 bytes apart in their block, and the int objects those pointers lead to sat 320 bytes apart on this run. The list pays an extra lookup for its flexibility, and the array pays with a fixed size for its directness.
Python’s array module supplies the typed middle case: it stores C-type values in a compact row, and the run measured itemsize 4 for type ‘i’.
The list looks like an array and behaves like one for reading, which is why the two get confused. Underneath, one stores values and the other stores directions to values, and that difference decides the memory bill.
Two dimensions are one line of memory
A grid is a flat row with a second index. grid[2][3] holds six ints in one line, row 0 first and row 1 after it, because C stores rows in order: row-major. grid[1][0] sat 12 bytes from the base, three ints on, and grid[0][5] read 6, the last element, through the first row’s name.

Rows are not equal in all languages. In C the grid is rectangular by construction, both rows holding three. In Java and JavaScript the rows are separate arrays, so one row can hold three and the next five: a jagged grid. The flat row is the C rule; the jagged row is the other languages’ choice.
The flat row also decides speed. Walking 4 million ints in order cost 0.57 nanoseconds per element. Walking with a stride of 16 cost 1.43 nanoseconds per element, 2.53 times as much, while touching one sixteenth of the values. The strided walk reads fewer elements and still costs more per element. A read pulls a 64-byte cache line and uses one value from it, while the ordered walk uses all 16 ints the line holds.
Why is a strided walk slower per element? Because the cache fetches neighbours whether they are read or not. A stride of 16 ints throws away 15 of 16 fetched values, so a useful read pays for a full line.
The timing flipped my expectation: fewer reads, more cost per read. The count of elements read is the wrong number to watch; the count of cache lines touched is the one that sets the price.
Reach for a fixed array when you know the count and the row is walked in order. Take a Python list when the count changes while the program runs. A typed array fits when the values are all numbers and memory is tight. The choice is the row’s shape against the job, and the index arithmetic underneath is identical in all three.
Frequently asked questions
Can an array hold values of different types?
A C array cannot: all slots hold the type the array was declared with, and a value of another type is converted on assignment. A Python list can: it stores pointers, and a pointer may lead to an object of any type. The typed array module sits between the two: one type, fixed, like C, with append, like a list.
What happens if I write past the end of an array?
The write lands on whatever sits past the row, usually another variable, and changes its value without warning. The program keeps running with corrupted data, and the failure shows up far from the write that caused it. That silent corruption is why bounds checks exist in other languages.
How big can an array be?
A local array is limited by the stack, commonly 8 MB, so a million-int row belongs on the heap instead. A heap array is limited by available memory. The size itself is not the limit; where the row lives decides it.
Is a string an array?
In C, yes: a string is an array of characters ending with a zero byte, and the zero marks the end because the array carries no length. In Python, a string is its own type, and indexing reaches into it by position.
What is the difference between an array and a linked list?
An array stores its values side by side and reaches any element with one calculation. A linked list stores a value in its own node with a pointer to the next, so reaching the tenth element means walking nine pointers. The array wins on access; the list wins on insertion in the middle.
Do all languages number arrays from 0?
No. C, Python, Java, and JavaScript start at 0, because the index counts steps from the base. Lua, Fortran, and MATLAB start at 1, because the index counts the position. The two conventions agree on the mechanism and differ on where the counting starts.

Kaleem
Kaleem is a Computer Science graduate (Virtual University of Pakistan) and the founder and editor of Valley AI, where he publishes in-depth, tested guides on computer hardware, artificial intelligence, and how the internet works. Every guide is researched from primary sources, tested hands-on where possible, and updated when the facts change.