/* Name: Matthew Weathers Oct 2004 * * array.cpp -- A simple example of an array * */ #include <iostream> #include <string> #define ARRAYSIZE 10 using namespace std; void main() { int x[ ARRAYSIZE+1 ]; // Declare the array int i; int sum; cout << "Please enter " << ARRAYSIZE << " integers: "; // A loop to get the values for(i=1; i<=ARRAYSIZE; i++) { cin >> x[i]; } sum=0; cout << "The sum is: "; // A loop to sum the values for(i=1; i<=ARRAYSIZE; i++) { sum+=x[i]; } cout << sum << endl; for (i=0; i<=ARRAYSIZE ; i++) { cout << "The value of x[" << i << "] "; cout << "is " << x[i] << endl; } } //end main()