twitter
    Find out what I'm doing, Follow Me :)

An Array Of Integers

Load the fileintarray.c and display it on your monitor for an example of an array of integers.


main( )
{
int values[12];
int index;
for (index = 0;index < 12;index++)
values[index] = 2 * (index + 4);
for (index = 0;index < 12;index++)
printf("The value at index = %2d is %3d\n",index,values[index]);
}



Notice that the array is defined in much the same way we defined an array of char in order to do the string
manipulations in the last section. We have 12 integer variables to work, with not counting the one named "index". The names of the variables are "values[0]", "values[1]", ... , and "values[11]". Next we have a loop to assign nonsense, but well defined, data to each of the 12 variables, then print all 12 out. You should have no trouble following this program, but be sure you understand it.

Compile and run it to see if it does what you expect it to do