// Program 7-5Modified.cpp is Pr7-5 modified by adding output statements and // increasing the value of MAX from 5 to 10. // I also stored the actual values of count in the values array and beyond array bounds. // This program unsafely accesses an area of memory by writing beyond the end of the array. // WARNING: If you compile and run this program, it may crash. #include using namespace std; int const MAX = 10; int main() { const int SIZE = 3; // Constant for the array size int values[SIZE]; // An array of 3 integers int count; // Loop counter variable // Attempt to store ten numbers in the three-element array. cout << "I will try to store too many numbers in a 3 element array!\n"; for (count = 0; count < MAX; count++) { values[count] = count; // Stores the count in values } // If the program is still running, display the numbers. cout << "If you see this message, it means the program\n"; cout << "has not crashed! Here are the numbers:\n"; for (count = 0; count < MAX; count++) cout << values[count] << endl; cout << "But the program does crash anyway!!!!\n"; return 0; }