Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help
next up previous
Next: Character arrays Up: C++ Summary Previous: Enumerated types

Arrays

Arrays are used to construct variables with multiple components of identical type. Components are accessed via one or more array index expressions within brackets []. Some examples of the definition and use of arrays are:

float       vector[100];         // elements vector[0] .. vector[99]
float       matrix[100][100];    // 2-D array

for (int i = 0; i < 100; i++)        // zero array vector
   vector[i] = 0.0;

matrix[2][4] = vector[3];        // 2-D and 1-D accesses
© Cambridge University Engineering Dept
Information provided by Tim Love
2006-12-08