// Shell Program - Examples of sequential array processing #include // I/O functions #include // I/O formatting functions #include // string class #include // abs(), rand(), atof(), etc. #include // exp(), pow(), trig functions, floor/ceiling, etc. const int NUM_ELEMENTS = 10; using namespace std; int main() { int myArray[ ] = {23, 45, 1, 8, -17, 133, 2, 0, 10, 9}; int i; // loop control int sum; // accumulates sum int largest, largestIndex; // holds current largest // find the sum of the elements in an array & display to screen sum = 0; for (i = 0; i < NUM_ELEMENTS; i++) sum = sum + myArray[i]; cout << "The sum of the array elements is " << sum << "." << endl; // find the largest element in the array and display to screen largest = myArray[0]; // initialize largest for (i = 1; i < NUM_ELEMENTS; i++) if (myArray[i] > largest) { largest = myArray[i]; largestIndex = i; } cout << "The largest element in the array is " << largest << "." << endl; return 0; }