Arrays
Not legal to place the square brackets after type as in Java
double[ ] limits = {10, 12, 14, 17, 0}; // legal Java, not C++
The limit can be omitted when arrays are passed as arguments to a function.
// compute average of an array of data values
double average (int n, double data[ ] )
{ double sum = 0;
for (int i = 0; i < n; i++) {
sum += data[i];}
return sum / n; }
Previous slide
Next slide
Back to first slide
View graphic version