// Soln4_1.cpp #include #include using std::cin; using std::cout; using std::endl; using std::setw; int main() { int arraySize = 5; double* values = new double[arraySize]; // Initial array to store values double* temp = 0; // Temporary store for new array double inputValue = 0.0; // Current input value int index = 0; // Index to the values array for(;;) { // Read the next value cout << "Enter a value or 0 to end: "; cin >> inputValue; // If it is 0 we are done so exit the loop if(inputValue == 0.0) break; values[index++] = inputValue; // Store the value and increment index if(index == arraySize) // If index reaches arraySize { // We need a bigger array... arraySize += 5; // Increase the array size value temp = new double[arraySize]; // Allocate the new array for(int i = 0 ; i