An array is a collection of data of a given type. Each element in the array is at a given index. An array element is the individual data segment or piece in the given array. An array index is the position in the array that a given element is at. Think of houses on a street. Each one is at a specific spot on the street. Thus, we could index them, or give them a number so we can remember where they are. Indexes start at 0 and go through the size of the array minus one.
Here is an example:
Code:
#include <stdio.h>
int main( void )
{
int houses[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int myhouse = 3;
printf("My house is at index 3. So...\n");
printf("houses[3] contains the value %d", houses[myhouse] );
return 0;
}
What do you think the value you get for houses[3]?
Were you right?
I'll leave working with loops as an exercise to the reader. But there is a brief example of how arrays work.
Quzah.