An array is a data structure which holds a fixed number of variables. All the variables must be of the same type. Instead of declaring ten integer values, you could define a single array with size equal to ten:
int a0, a1, a2, a3, a4, a5, a6, a7, a8, a9;
vs.
int a [10];
for (i = 0; i < 10; i++) a[i] = 0;
Notice that i goes from 0 to 9. It is very important that you stay within the 'bounds' of the array. Compilers don't always catch errors like: a[10] = 0; and they can have very destructive results.
Above, we've declared an array of integers. More generally, you can create an array that holds any type of value like this:
variable_type array_name [ size ];Under some circumstances, you may want to initialize the array at the same time you declare it. When you do this, you don't need to define the size of the array. The size is really just there to indicate to the computer how much space to allocate for the array. By initializing the array when you define it, you implicitly define the size of the array. Here's an example of an array of integers (size = 9)
int my_array [] = {1, 5, 8, 23, 56, 2, 9, 5, 8};