Code About Us Tutorial


  Arrays
    What is an Array?
    Array Elements
    Filling an Array
    Initializing An Array
    Multidimensional Arrays


   
 

Home > Arrays > What is an Array?

November 26, 2009 10:01 pm

   

What is an Array?

An array is a sequence of objects all of which have the same variable type. Each storage location or object are called the elements of the array and are numbered in a row 0, 1, 2, 3, etc. These numbers are called index values of the array.

The syntax of an array is as follows:

 

 
Type array-name [array-size];

Where type is the array’s element type it could be replaced, for instance with: int, float, char, etc. (These terms will be explained later). The array-size is the number of elements in the array. Here is an example of a declaration of an array.

 

 
int anArray[5];

Explanation of declaration: First off, the type of array is an integer, the array-name is anArray and finally the array-size has 5 elements. The next section will explain how elements are used in arrays. Please Rate this Code:


    Comments for: What is an Array?
Annonymouse User says:
Arrays Are cool!! 2d arrays are:

[code]type arran-name [array 1st-d size][2nd-size]; [/c





Add Comment:
Name:
Email:


 «6» THINKQUEST TEAM C0111571 © 2001. All Rights Reserved.