#include #include #include // This program stores values in an array that has // room for at most five entries. // // The first two entries are entered by the user. // Additional entries are then calculated and added // to the array. // // The variable 'capacity' records how many entries // of the array are currently being used. // // Only increase the capacity of the array when a // new entry is actually added. // // Find and fix any bugs. // Function declarations int main(); // Function definitions int main() { double array[5]; std::size_t capacity{ 0 }; std::cout << "Enter a real number: "; std::cin >> array[0]; std::cout << "Enter a second real number: "; std::cin >> array[1]; capacity = 2; if ( array[0] < array[1] ) { array[capacity] = array[1] - array[0]; ++capacity; } else if ( array[1] < array[0] ) { array[capacity] = array[0] - array[1]; ++capacity; } if ( std::abs( array[0] - array[1] ) < 1 ) { array[capacity] = 1 - array[0] - array[1]; ++capacity; } for ( std::size_t k{ 0 }; k < capacity; ++k ) { std::cout << array[k] << " "; } std::cout << std::endl; return 0; }