// Examples of array use #include using namespace std; int main() { const int SIZE = 15; int i; // loop counter int sum = 0; // accumulator variable int list[SIZE]; /* initialize to a pattern, with a for-loop */ for (i = 0; i < SIZE; i++) list[i] = 3 * i + 1; /* print contents */ cout << "\nThe list: "; for (i = 0; i < SIZE; i++) cout << list[i] << ' '; /* Let user type new values */ cout << "\nPlease enter " << SIZE << " new array elements: "; for (i = 0; i < SIZE; i++) cin >> list[i]; /* print contents */ cout << "\nThe list: "; for (i = 0; i < SIZE; i++) cout << list[i] << ' '; /* print contents backwards */ cout << "\nThe list backwards: "; for (i = SIZE-1; i >= 0; i--) cout << list[i] << ' '; /* Now add the array contents */ for (i = 0; i < SIZE; i++) sum = sum + list[i]; cout << "\nThe sum of the array elements is: " << sum << '\n'; return 0; }