An array is a row of boxes
An array is several boxes of the same type side by side in memory. squares[0] is the first box and squares[4] is the last; there is no squares[5].
Watch the loop write one box per pass, using i as the index.
#include <stdio.h>
int main(void) {
int squares[5] = {0};
for (int i = 0; i < 5; i++) {
squares[i] = i * i;
}
printf("%d %d\n", squares[2], squares[4]);
return 0;
}
Output:
4 16
From the lesson: Arrays