CS561-SPRING 2002

TOPIC:CS105-ARRAYS

 

              Array declarations are generally of the format described below 

<Data type>  <Array name>  <Array dimensions> 

                     A typical static array declaration for a simple program in C++ would look like 

Example :: int   HOLD_INT   [10];  

                    where “int” signifies the fact that this array is created and meant to hold exclusively, integers in its locations, “HOLD_INT” is the name of the array, which is used to access the locations and elements it holds and “[10]” is the size of the array or the maximum number of elements it is allowed to store. Such a declaration would set aside 10 memory locations that are reserved for storing integers and are accessed by the “HOLD_INT” array pointer.

                       The above is an example for a single dimension array, there are two dimensional arrays also that are used frequently and in the next example we will explore the same.

 

<=PREV                                       HOME                                               NEXT=>